I added a new parameter name Walk type trigger.
And a screenshot of the transition :
And the code in the Update :
private void Update()
{
if (startRotating)
{
if (rotateTowards)
{
if (rotateTowardsObject)
{
anim.SetTrigger("Walk");
Vector3 targetDirection = objectToRotatetowards.position - transform.position;
float singleStep = rotationSpeed * Time.deltaTime;
Vector3 newDirection = Vector3.RotateTowards(transform.forward, targetDirection, singleStep, 0.0f);
transform.rotation = Quaternion.LookRotation(newDirection);
}
}
}
}
The rotation start once the flag rotateTowardsObject is true but the "Walk" state animation taking 5 seconds even a bit more to start.
CodePudding user response:
On your transition, you should uncheck Has Exit Time
Keeping this checked makes the animator wait until end of your transitioning animation.