- Home /
Mobile Skater game question
what code do I use to make the skater "leanLeft" during a left rotation and "leanRight" during a right rotation? If you have worked with this tutorial and know the answer please give me some code for this. I have a animation for both leanLeft and LeanRight.
Answer by IT_Criminal · Nov 25, 2012 at 08:36 AM
well ... you read the object left/right velocity using
character_controller.velocity.x
(note that you must make a variable of CharacterController type named character_controller and then assign the character_controller in the inspector)
and then rotate your character (or play animation) depending on that
example
if(character_controller.velocity.x > 2)
{
animation.CrossFade("leanRight",0.2);
}
if(character_controller.velocity.x < 2)
{
animation.CrossFade("leanLeft",0.2);
}
I have tried to do this with the result the character controller leans right and the skater shrinks to .2 in size with no steering control. I think the answer has to do with the look rotation. I still would love to get this to work as I have been trying to do this for months.
Your answer
Follow this Question
Related Questions
Need GUIDANCE On Mobile Accelerometer Input Applied to Rigidbody 1 Answer
how to move an object in 4 directions by tilting device when not parallel to the ground 0 Answers
Detect if running on mobile vs desktop 2 Answers
How to get different Animations when different button combos are pressed 2 Answers
Mobile/Particles/Alpha Blended + UV animation problem 0 Answers