- Home /
Character Model direction
Hi , I have a character with a character controller , and the character model is a child of the the character controller object , my character can move on all directions , how can i make the character model rotates to the direction that the character moves to ? , thanks for your time
Answer by asafsitner · Feb 18, 2012 at 02:38 PM
To calculate the movement vector you basically subtract your last position from your current position, then normalize it. Then assign this value to the model's parent's forward
property and you're set.
This simple line of code should do:
myModel.forward = (myTransform.position - myTransformLastPosition).normalized;
Remember to cache your transform's position as the last thing in your Update method.
it worked but he looks at the direction very slow , how can i fix that ?