Hi guys
I recently started with untiy and I’m trying to recreate PacMan.
Right now I’m working on the PlayerMovement script and have a problem with the rotation.
I want the character to always look at the direction it moving. In PacMan there are only 4 directions (Up, Left, Down, Right)
I tried a lot of stuff already. I have to add to this that, even if I have some basic programming knowledge, I can’t wrap my head around the whole rotation/quaternion thing.
i.e.
I wanted to use Quaternion.slerp but with that I didn’t know how I can set the target direction
Please help me or if possible, lead me to a pleace, where the whole rotation thing is explained in a way that I can understand it.
Thanks a lot.
This is what I have so far:
var player : Transform; var moveSpeed = 10; var rotateSpeed = 10; //This was my idea to have fixed points to rotate to... var directionLeft = Vector3(1,0,0); var directionRight = Vector3(-1,0,0); var directionUp = Vector3(0,0,-1); var directionDown = Vector3(0,0,1); function Update(){ var controller : CharacterController = GetComponent(CharacterController); //this is just for the "up" direction if (Input.GetButton("Move Up")) { controller.SimpleMove(directionUp * moveSpeed); //here would be the roationscript }