![]() If (left & rotation is not equal to (0, 180, 0)) The code would look something like (writing it out): private int GetAxisRaw(Axis axis) ![]() If it isn't, set it to (0, 180, 0) for instance. My logic would be to store the rotation value somewhere (type Quaternion/bool maybe) and check to see if that rotation value matches up with the current rotation value set to left (which is (0, 180, 0) ) If that's the case, don't do anything. (0, -180, 0) Īs you can see the (0, 180, 0) is getting called each time the player presses the left key for instance, thus turning the head of the snake even when the snake is still traveling to the left. ![]() (0, 180, 0) // Keeps rotating when left is pressed I tried to look it up, but none of the answers are specific to what I'm trying to do.Īs of right now this is what I have for player input (a snippet of code): private int GetAxisRaw(Axis axis)īool left = Input.GetKeyDown(Ke圜ode.LeftArrow) || Input.GetKeyDown(Ke圜ode.A) īool right = Input.GetKeyDown(Ke圜ode.RightArrow) || Input.GetKeyDown(Ke圜ode.D) This is for a snake game (like the old top down nokia game) I'm currently developing. ![]() I'm trying to check if an object (a head) is facing a certain direction, if it's not facing that direction it needs to set it to that direction depending which way it goes (up, down, left or right). I can usually find my way around when it comes to setting/changing the position of an object, but when it comes to rotation it's still mind boggling to me, with quaternion, eulerangles etc. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |