- Home /
Question by
julinzp · Nov 07, 2018 at 01:50 PM ·
rotationmovementquaternioncoroutinerotation axis
How to turn a character frame independently?
I have a humanoid character with some animation from raw mocup which performs some movement. At some point I want it to change the direction. However the question is how to make turn smoothly. At this point i just use rotation but it looks sharpy
void Turning(int Angle)
{
bool IsTurningLeft = RandomBool();
if (IsTurningLeft == true)
{
transform.Rotate(new Vector3(0, -1 * Angle, 0));
}
else
{ //Turning right
transform.Rotate(new Vector3(0, Angle, 0));
}
}
IEnumerator Actionl()
{ Walking();
yield return new WaitForSeconds(2f);
Turning(45);
SpeedChange(2f);
Standing();
yield return new WaitForSeconds(5f);
Walking();
yield return new WaitForSeconds(3f);
}
void Start()
{
anim = GetComponent<Animator>();
StartCoroutine("Action");
}
Comment
Answer by hameed-ullah-jan · Nov 07, 2018 at 02:53 PM
you are using "transform.Rotate" outside the update() function, try to use this function inside update() and make the angle multiple of Time.deltatime.
But I don't want to make it turn forever, what could be the correct way to exit the turning execution?
Your answer
Follow this Question
Related Questions
Quaternion LookRotation issue 0 Answers
Help with rotating a sprite with mouse. 2 Answers
Animator movement and mouse position problem 0 Answers