CODE
     

///////////////////////////////////////////////////////
////////////////REWIND TIME////////////////////////////
///////////////////////////////////////////////////////
/*
This code will let you Save and Rewind an Objects Position, Rotation, and Velocity. It's not perfect but works.'
*/


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class REWINDING : MonoBehaviour {
	bool isRewinding = false; //are we currently Rewinding TIme?
	List<PointInTime> pointsInTime; //The points of time to record (See bottom)
	Rigidbody rb; //our RigidBody (if we have one);
	public Slider timebar; //A Slider to visually keep track of time.
	bool canRecord = true; //Checks if need to be recording...
	Vector3 tempVelocity; //Holding place for Velocity
	Vector3 tempAngVelocity; //Holding place for Velocity
	float timeLimit = 5f; //How many seconds to store;
	//TOGGLEABLES  (When all of these are off, Game will continually Record and loop over old data keeping everything in sync.
	bool onlyWhenMoving = false; //Check if you only want to record Position Change (IE: no stopped Movment, multiple objects record their OWN time within the limit.)
	bool hardTimeLimit = false; //Check if you want to record a Specific amount of time. (IE: no overlap
	bool toggleRecord = false; // allow toggling time recording on/off;

	void Start () {
		canRecord = !toggleRecord;//Presets Game to Start recording or not.
		rb = GetComponent<Rigidbody> (); //Get our RigidBody(if we have one)
		pointsInTime = new List<PointInTime> ();//start our points in time variable
		if(onlyWhenMoving){
			pointsInTime.Insert (0, new PointInTime(transform.position,transform.rotation,rb.velocity,rb.angularVelocity));//Insert the first Point in Time
		}
	}
	void FixedUpdate(){
		//We run in here the Get and Restore time points so its not happening every Frame
		if (isRewinding) {
			Rewind ();
		} else {
			Record ();
		}
	}
	void Record(){
		if (canRecord) {
			int timeLimitCheck = Mathf.RoundToInt (timeLimit / Time.fixedDeltaTime);//gets current time limit check and converts to int

			if (onlyWhenMoving && transform.position == pointsInTime [0].position) { //for when we dont want to record non movement
				return;//Dont Record Stopping
			}
			if (hardTimeLimit) {//If we only want to Record a specific Track of time.. No matter what happens after the time limit. It only records this time.
				if (pointsInTime.Count < timeLimitCheck) {//Check if time limit reached
					pointsInTime.Insert (0, new PointInTime (transform.position, transform.rotation, rb.velocity,rb.angularVelocity));//Adds points in time to the Beggining of list
					if(timebar!=null){
						timebar.value = pointsInTime.Count;//Updates Slider
					}
				}
			} else {//if we want to record a looping time (erasing earlier data and adding new
				pointsInTime.Insert (0, new PointInTime (transform.position, transform.rotation, rb.velocity,rb.angularVelocity));//Adds points in time to the Beggining of list
				if (pointsInTime.Count > timeLimitCheck) {//Check if time limit reached if yes, remove newest added element
					pointsInTime.RemoveAt (pointsInTime.Count - 1);
				}
				if(timebar!=null){
					timebar.value = pointsInTime.Count;//Updates Slider
				}
			}
		}
	}
	void Rewind(){
		if (canRecord) {
			if (pointsInTime.Count > 0) {//If we have Any points in time.....
				transform.position = pointsInTime [0].position;//Sets position of current point
				transform.rotation = pointsInTime [0].rotation;//Sets rotation of current point
				rb.velocity =  pointsInTime [0].velocity;
				rb.angularVelocity =  pointsInTime [0].angVelocity;
				tempVelocity = pointsInTime [0].velocity;//Sets velocity of current point
				tempAngVelocity = pointsInTime [0].angVelocity;//Sets velocity of current point
				pointsInTime.RemoveAt (0);//Removes the Current point so next one fills in
				if(timebar!=null){
					timebar.value = pointsInTime.Count;//Updates Slider
				}
			}
			if (pointsInTime.Count == 0) {//if for some reason we have no new points.. Make current points the first one (fixes issues with OnlyWhenMoving
				pointsInTime.Insert (0, new PointInTime (transform.position, transform.rotation, rb.velocity,rb.angularVelocity));
			}
		}
	}
	void ResetRecordings(){//Clears out recordings.
		pointsInTime.Clear();
		if (onlyWhenMoving) {
			pointsInTime.Insert (0, new PointInTime(transform.position,transform.rotation,rb.velocity,rb.angularVelocity));//Insert the first Point in Time
		}
	}

	void Update () {
		if (isRewinding == false) {//For TESTING
			//rb.velocity = new Vector3 (Input.GetAxis ("Horizontal")*5, rb.velocity.y, Input.GetAxis ("Vertical")*5);
		}
		if (Input.GetKeyDown (KeyCode.Space)) {//FOR TESTING
			rb.AddForce (Vector3.up*5f,ForceMode.Impulse);
		}
		if (Input.GetKeyDown (KeyCode.T) && toggleRecord) {//Toggle recording. Upon doing so, ResetsRecordings.
			canRecord = !canRecord;
			if (canRecord) {
				ResetRecordings ();
			}
			if(timebar!=null){
				timebar.value = pointsInTime.Count;//Updates Slider
			}
		}
		if (Input.GetKeyDown (KeyCode.R)) {//Start Rewinding while Held DOwn
			if (canRecord) {
				StartRewind ();
			}
		}if (Input.GetKeyUp (KeyCode.R)) {//Stop Rewinding upon Release
			if (canRecord) {
				StopRewind ();
			}
		}
	}
	void StartRewind(){//Start Rewinding. Sets kinematic true to avoid weird physics issues
		isRewinding = true;
		rb.isKinematic = true;
	}
	void StopRewind(){//Start recording. Sets kinematic false to reactivate physics
		isRewinding = false;
		rb.isKinematic = false;
		rb.velocity = tempVelocity;
		rb.angularVelocity = tempAngVelocity;
	}

}

public class PointInTime{
	public Vector3 position;
	public Quaternion rotation;
	public Vector3 velocity;
	public Vector3 angVelocity;
	public PointInTime (Vector3 _position, Quaternion _rotation,Vector3 _velocity,Vector3 _angVelocity){
		position = _position;
		rotation = _rotation;
		velocity = _velocity;
		angVelocity = _angVelocity;
	}
}



    
CODE
     
///////////////////////////////////////////////////////
////////////////Code////////////////////////////
///////////////////////////////////////////////////////


    
CODE
     
///////////////////////////////////////////////////////
////////////////Code////////////////////////////
///////////////////////////////////////////////////////


    
CODE
     
///////////////////////////////////////////////////////
////////////////Maze Generator/////////////////////////
///////////////////////////////////////////////////////
/*
This code will create a randomly generated maze
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MazeGenerator : MonoBehaviour {
	[Range(2,50)]
	public int mazeSizeX = 15;//Max Size of X coordinate of Maze in Cells
	[Range(2,50)]
	public int mazeSizeY = 25;//Max Size of Y coordinate of Maze in Cells (technically Z)
	[Range(1,30)]
	public float roomSize = 2f;//This is the Actual Room Size after done.
	[Range(1,10)]
	public float wallHeight = 1.5f;//this is the Actual Room Height
	[Range(0.125f,5)]
	public float wallThickness = 0.125f;//Thickness of the walls
	bool slowmoMode = true;

	//sets the Poles (the identifiers for testing purposes.
	public Transform nPole; 
	public Transform sPole;
	public Transform ePole;
	public Transform wPole;
	public GameObject fpsPrefab;
	//Prefabs for the Maze itself
	public GameObject floorPrefab;
	public GameObject ceilingPrefab;
	public GameObject hWallPrefab;
	public GameObject vWallPrefab;
	public GameObject startingPointPrefab;//Prefab to mark the Starting Loc (GREEN)
	public GameObject endingPointPrefab;//Prefab to mark the ending Loc (RED)

	GameObject[,] hWallsList; //Horizontal Wall List
	GameObject[,] vWallsList; //Vertical Wall List

	bool[,] roomsVisited; //Marks off rooms visited to keep track of what has and hasn't been used.
	Vector2 currentPos; //current position being checked the the generator
	Vector2 prevPos; //most recent position being checked by the generator
	bool searching = false; //if we are still searching for parts of the maze
	int dir; //the direction for the maze to check to add new walls.
	int totalRoomCount; //countdown to know when the rooms have all been checked
	bool mazeBlockedOut = false; //tells us when the maze has been Blocked Out
	bool mazeCutOut = false; // Tells us when the maze has been Cut
	Vector2 startPos; //The position to start, randomly chosen
	Vector2 endPos; //the last position to be cut, also the Ending?

	void Start () {
		mazeSizeX = Mathf.Clamp (mazeSizeX, 2, 50);//Don't allow the maze to be below 2, Maximum is more optional
		mazeSizeY = Mathf.Clamp (mazeSizeY, 2, 50);//Don't allow the maze to be below 2, Maximum is more optional
		roomSize = roomSize + (roomSize * wallThickness)+wallThickness;//Adjusts the roomsize using other properties (thickness of walls, and spacing.
		totalRoomCount = mazeSizeX * mazeSizeY; //The total room count we should end up with.
		hWallsList = new GameObject[mazeSizeX+1, mazeSizeY+1]; //setting up the lists
		vWallsList = new GameObject[mazeSizeX+1, mazeSizeY+1]; //setting up the lists
		roomsVisited = new bool[mazeSizeX+1, mazeSizeY+1]; //setting up the lists
	}

	void Update () {
		if (Input.GetKeyDown (KeyCode.Q) && searching==false && mazeCutOut==false && mazeBlockedOut==false) {
			MakeGrid (mazeSizeX*mazeSizeY);
		}
	}


	void MakeGrid(int totalSpaces){//This function creates the Grid From Left to right, then top to bottom
		if (mazeBlockedOut == false) {//Check if the maze has been blocked out
			GameObject go; // var for the walls
			int iH = 0; //horizontal wall position
			int iV = 0; //vertical wall position
			int iHc = 0; //horizontal wall count (when to return and drop to next vertical level)
			for (int i = 0; i < totalSpaces; i++) {
				go = Instantiate (hWallPrefab, new Vector3 (iH*roomSize, 0, iV*roomSize), Quaternion.identity); //create a horizontal wall at the position
				go.transform.localScale = new Vector3 (roomSize,wallHeight,(wallThickness)*roomSize); //scale the wall based on the public parameters
				go.GetComponent<MeshRenderer> ().material.SetTextureScale ("_MainTex", new Vector2 (go.transform.localScale.x/roomSize,go.transform.localScale.y/roomSize));//adjust the textures scale
				hWallsList [iH, iV] = go; // set the horizontal wall list to this game object
				go.name = iH + ":" + iV; // name the wall for easier testing and editing in inspector
				go = Instantiate (vWallPrefab, new Vector3 ((iH - 0.5f)*roomSize, 0, (iV + 0.5f)*roomSize), Quaternion.identity);//create vertical wall at the position
				go.transform.localScale = new Vector3 ((wallThickness)*roomSize,wallHeight,roomSize);//scale the wall based on the public parameters
				go.GetComponent<MeshRenderer> ().material.SetTextureScale ("_MainTex", new Vector2 (go.transform.localScale.z/5f,go.transform.localScale.y/roomSize));//adjust the textures scale
				vWallsList [iH, iV] = go;// set the vertical wall list to this game object
				go.name = iH - .5f + ":" + (iV + .5f);// name the wall for easier testing and editing in inspector
				iHc++;//Keep count of current Horizontal walls to know when to track to next line
				iH++;//Keep count of current Horizontal walls
				if (iHc >= mazeSizeX) {//if the horizontal count reaches max, move to next line
					go = Instantiate (vWallPrefab, new Vector3 ((iH - 0.5f)*roomSize, 0, (iV + 0.5f)*roomSize), Quaternion.identity);//create the last horizontal line for this row
					go.transform.localScale = new Vector3 ((wallThickness)*roomSize,wallHeight,roomSize);//scale the wall based on the public parameters
					go.GetComponent<MeshRenderer> ().material.SetTextureScale ("_MainTex", new Vector2 (go.transform.localScale.z/roomSize,go.transform.localScale.y/roomSize));//adjust the textures scale
					hWallsList [iH, iV] = go;// set the horizontal wall list to this game object
					go.name = iH - .5f + ":" + (iV + .5f);// name the wall for easier testing and editing in inspector
					iV++;//next vertical line
					iH = 0;//reset horizontal
					iHc = 0;//reset horizontal counter
				}
			}
			for (int i = 0; i < mazeSizeX; i++) {//This part just creates the last line of Horizontal Walls
				go = Instantiate (hWallPrefab, new Vector3 (iH*roomSize, 0, iV*roomSize), Quaternion.identity);
				go.transform.localScale = new Vector3 (roomSize,wallHeight,(wallThickness)*roomSize);
				go.GetComponent<MeshRenderer> ().material.SetTextureScale ("_MainTex", new Vector2 (go.transform.localScale.x/roomSize,go.transform.localScale.y/roomSize));
				go.name = iH + ":" + iV;
				iH++;
			}
			//These are just for moving the navigation blocks for easier tests
			nPole.position = new Vector3 ((mazeSizeX/2f)*roomSize, 0f, (mazeSizeY+2f)*roomSize);
			sPole.position = new Vector3 ((mazeSizeX/2f)*roomSize, 0f, (-2)*roomSize);
			ePole.position = new Vector3 ((mazeSizeX+2f)*roomSize, 0f, (mazeSizeY/2f)*roomSize);
			wPole.position = new Vector3 ((-2f)*roomSize, 0f, (mazeSizeY/2f))*roomSize;
			mazeBlockedOut = true; //Maze is blocked out
			CutStart(); //start cutting the maze
		}
	}









	void CreateEndPos(){//Creates a random End Pos
		endPos = currentPos;
		GameObject go = Instantiate (endingPointPrefab,new Vector3((endPos.x)*roomSize,0,(endPos.y+0.5f)*roomSize), Quaternion.identity);
		go.transform.localScale = new Vector3 (roomSize/2f, wallHeight*0.75f, roomSize/2f);
	}
	void CutStart(){//Choose a starting Position
		if (mazeBlockedOut == true && mazeCutOut == false) { //Check if maze has been blocked out, and if maze has been started.
			startPos = new Vector2 (Mathf.FloorToInt(Random.Range (0, mazeSizeX)), Mathf.FloorToInt(Random.Range (0, mazeSizeY))); //Choose a random Starting Position inside of the maze
			roomsVisited [Mathf.RoundToInt (startPos.x), Mathf.RoundToInt (startPos.y)] = true;//Set the start locations location as visited
			Instantiate (fpsPrefab,new Vector3((startPos.x)*roomSize,0,(startPos.y+0.5f)*roomSize), Quaternion.identity);//Create a prefab of the FPS for testing purposes
			GameObject go = Instantiate (startingPointPrefab,new Vector3((startPos.x)*roomSize,0,(startPos.y+0.5f)*roomSize), Quaternion.identity); //Create a prefab to indicate the prefab for testing purposes
			go.transform.localScale = new Vector3 (roomSize/2f, wallHeight*0.75f, roomSize/2f);//Resize the Starting Indicator
			prevPos = startPos;//set the prev location to the start location
			currentPos = startPos; //set the current location to the start location
			totalRoomCount--; //Subtract room count
			go = Instantiate (floorPrefab,new Vector3(((mazeSizeX*roomSize)/2f)-(0.5f*roomSize), (-1*(wallHeight/2))-0.05f, ((mazeSizeY*roomSize)/2f)), Quaternion.identity); //create the floor prefab
			go.transform.localScale = new Vector3 (mazeSizeX*roomSize, 0.1f, mazeSizeY*roomSize); //Scale the floor Prefab
			go.GetComponent<MeshRenderer> ().material.SetTextureScale ("_MainTex", new Vector2 (mazeSizeX,mazeSizeY)); //Change texture size of ceiling prefab
			go = Instantiate (ceilingPrefab,new Vector3(((mazeSizeX*roomSize)/2f)-(0.5f*roomSize), (wallHeight/2)+0.05f, ((mazeSizeY*roomSize)/2f)), Quaternion.identity);//create the ceiling prefab
			go.transform.localScale = new Vector3 (mazeSizeX*roomSize, 0.1f, mazeSizeY*roomSize);//Scale the floor Prefab
			go.GetComponent<MeshRenderer> ().material.SetTextureScale ("_MainTex", new Vector2 (go.transform.localScale.x/mazeSizeX,go.transform.localScale.z/mazeSizeY));//Change texture size of ceiling prefab
			CutMaze();//cut the rest of the maze
		}
	}
	void FindRandomPlace(){ //if stuck, find a random place in the maze to start cutting from
		if (mazeBlockedOut == true && mazeCutOut == false) { //Check if Maze has been blocked out and if maze has already been cut
			currentPos = new Vector2 (Mathf.FloorToInt (Random.Range (0, mazeSizeX)), Mathf.FloorToInt (Random.Range (0, mazeSizeY)));//get the random location
			while (roomsVisited [Mathf.RoundToInt (currentPos.x), Mathf.RoundToInt (currentPos.y)] == false|| currentPos==startPos) {//check if random location has been found before or if it is start pos
				currentPos = new Vector2 (Mathf.FloorToInt (Random.Range (0, mazeSizeX)), Mathf.FloorToInt (Random.Range (0, mazeSizeY))); //if yes, keep checking then set currentpos

			}
			searching = false;//no longer searching
			prevPos = currentPos; //set prevpos
			CutMaze ();//backt o cutmaze with new info
		}
	}
	void CutMaze(){ //Cut the maze
		if (mazeBlockedOut == true && mazeCutOut == false) {//Check if Maze has been blocked out and if maze has already been cut
			searching = true; //are we searching for new location
			int triedRandom = 4;//times to try a random direction
			int triedForced = 4;//times to try a non random direction 
			while (searching == true) {//Start looking for new location
				triedRandom--;//count down till we try forced direction
				if (triedRandom < 1) {//if we have tried all of the random directions, run through all of the directions possible
					triedForced--;
					dir = triedForced;
					if (triedForced < 0) {
						//deadend = true;
						FindRandomPlace ();
						return;
					}
				} else {
					dir = Random.Range (0, 4);//Choose a random Direction  0=Up,1=down,2=left,3=right
				}
				if (dir == 0) {//N
					currentPos = prevPos + new Vector2 (0, 1); //set the position based on the direction we chose
					if (currentPos.y > (mazeSizeY - 1)) {//make sure we have not exceeded the bounds of the maze
						currentPos.y = (mazeSizeY - 1);
					}
				} else if (dir == 1) {//S
					currentPos = prevPos + new Vector2 (0, -1);
					if (currentPos.y < 0) {
						currentPos.y = 0;
					}
				} else if (dir == 2) {//W
					currentPos = prevPos + new Vector2 (-1, 0);
					if (currentPos.x < 0) {
						currentPos.x = 0;
					}
				} else if (dir == 3) {//E
					currentPos = prevPos + new Vector2 (1, 0);
					if (currentPos.x > mazeSizeX - 1) {
						currentPos.x = mazeSizeX - 1;
					}
				}


				if (roomsVisited [Mathf.RoundToInt (currentPos.x), Mathf.RoundToInt (currentPos.y)] == false) {//if the room has not been visited before.
					if (dir == 0) {//check the DIr
						hWallsList [Mathf.RoundToInt (currentPos.x), Mathf.RoundToInt (currentPos.y)].SetActive (false);//disable the wall between the last position and the new one
					} else if (dir == 1) {
						hWallsList [Mathf.RoundToInt (currentPos.x), Mathf.RoundToInt (currentPos.y + 1)].SetActive (false);
					} else if (dir == 2) {
						vWallsList [Mathf.RoundToInt (currentPos.x + 1), Mathf.RoundToInt (currentPos.y)].SetActive (false);
					} else if (dir == 3) {
						vWallsList [Mathf.RoundToInt (currentPos.x), Mathf.RoundToInt (currentPos.y)].SetActive (false);
					}
					prevPos = currentPos;//set prev to current
					roomsVisited [Mathf.RoundToInt (currentPos.x), Mathf.RoundToInt (currentPos.y)] = true;//set that room as visited
					totalRoomCount--;//countdown total rooms visited
					searching = false;//we are no longer searching yet
					if (totalRoomCount <= 0) {//if we have reached the total rooms available
						CreateEndPos();//Go to Create the end position
						mazeCutOut=true;//The maze has been Cut out and is DONE
					} else {//we have more rooms to find
						if (slowmoMode == true) {//if slowmode is true, we slowly create the maze
							Invoke ("Slowmo", 0.05f);
						} else {
							CutMaze ();//cut the next part of the maze
						}
					}

				} else {
				}
			}
		}

	}

	void Slowmo(){
		CutMaze ();
	}
}


    
CODE
     
///////////////////////////////////////////////////////
////////////////Code////////////////////////////
///////////////////////////////////////////////////////


    

Code Sources

Personal NOTE: Replace < with  &lt; when adding to HTML

CODE
     

///////////////////////////////////////////////////////
////////////////Sprite Facing//////////////////////////
///////////////////////////////////////////////////////
/*
This code allows for a Doom/Wolfenstein style billboard system to let the player see a 2d object as if it were 3d.
	*/

	/*
	To use this Code:
	Create your creature object (just an empty object with any of your creatures functional bits)
	create a sprite object (BILLBOARD) as a child of the empty object and place this code.
	Make sure you have a Spite Renderer on this object.
	Set the target you want to always bee looking at. (PLAYER)
	Place your Sprites in the spr array.
	0::Front
	1::Front Left
	2::Left
	3::back Left
	4::Back
	5::Back Right
	6::Right
	7::Front Right
	*/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpriteFacing : MonoBehaviour {

	public bool lockRotationToY = true;//Lock Rotation to Y only, Good for FPS, Turn off for top Down RPG Games.
	public Transform player;//The player so the Billboard is always facing YOU.
	float localRot;//Rotaion of the Local Sprite that Tracks the player.
	SpriteRenderer sr;//The spriterender on this Game Object.
	public Sprite[] spr;//The Sprites
	float degrees4Way = 90f/2f; //Amount of Degrees Between Sprites (Divided by 2 to get RANGE
	float degrees6Way = 45f/2f; //Amount of Degrees Between Sprites (Divided by 2 to get RANGE
	bool fourWayOn = false;//Choose between 4 and 6-way sprites
	void Start () {
		sr = GetComponent<SpriteRenderer> ();//Set our Sprite Renderer
	}

	void Update () {
		Vector3 v = player.position - transform.position; //the position of the player compared to us.
		if (lockRotationToY) {//Lock Rotation to Y, Good for FPS style games.
			v.x = v.z = 0.0f; //Setting the Rotation of the Z/X to zero
			transform.LookAt (player.position - v); //Look at the V position we calculated earlier
		} else {
			transform.LookAt (player.position); //Look at the V position we calculated earlier
		}
		localRot = transform.localEulerAngles.y; //Get the local rotation of the bilboard, this way we can rotate the parent and the billboard with still be correct
		//Change the billboard sprite based on the direction the player is seeing it.


		if (fourWayOn) {
			if (localRot > (90 - degrees4Way) && localRot <= (90 + degrees4Way)) {//FRONT 90
				sr.sprite = spr [0];
			}else if (localRot > (180 - degrees4Way) && localRot <= (180 + degrees4Way)) {//Left 180
				sr.sprite = spr [2];
			} else if (localRot > (270 - degrees4Way) && localRot <= (270 + degrees4Way)) {//Back 270
				sr.sprite = spr [4];
			} else if (localRot > (360 - degrees4Way) && localRot <= (360) || localRot > (0) && localRot <= (0 + degrees4Way)) {//Right 0/360
				sr.sprite = spr [6];
			}
		} else {
			if (localRot > (90 - degrees6Way) && localRot <= (90 + degrees6Way)) {//FRONT 90
				sr.sprite = spr [0];
			} else if (localRot > (135 - degrees6Way) && localRot <= (135 + degrees6Way)) {//Front Left 135
				sr.sprite = spr [1];
			} else if (localRot > (180 - degrees6Way) && localRot <= (180 + degrees6Way)) {//Left 180
				sr.sprite = spr [2];
			} else if (localRot > (225 - degrees6Way) && localRot <= (225 + degrees6Way)) {//Back Left 225
				sr.sprite = spr [3];
			} else if (localRot > (270 - degrees6Way) && localRot <= (270 + degrees6Way)) {//Back 270
				sr.sprite = spr [4];
			} else if (localRot > (315 - degrees6Way) && localRot <= (315 + degrees6Way)) {//Back Right 315
				sr.sprite = spr [5];
			} else if (localRot > (360 - degrees6Way) && localRot <= (360) || localRot > (0) && localRot <= (0 + degrees6Way)) {//Right 0/360
				sr.sprite = spr [6];
			} else if (localRot > (45 - degrees6Way) && localRot <= (45 + degrees6Way)) {//Front Right 45
				sr.sprite = spr [7];
			}
		}

		//sr.sprite = spr [Mathf.RoundToInt((Mathf.Abs(localRot-90))/45)]; Thise code returns the correct ID number for sprite except the  [Right 0/360]
	}
}


    
CODE
     
///////////////////////////////////////////////////////
////////////////Code////////////////////////////
///////////////////////////////////////////////////////


    
CODE
     
///////////////////////////////////////////////////////
////////////////Code////////////////////////////
///////////////////////////////////////////////////////


    
CODE
     
///////////////////////////////////////////////////////
////////////////Code////////////////////////////
///////////////////////////////////////////////////////