简体   繁体   中英

Why the object is never rotating towards the target?

void Update()
    {
        if (pickUp)
        {
            if(Roll.hasStopped)
            {
                animator.SetTrigger("Walk Forward");
                Vector3 targetDirection = (target.position - transform.position).normalized;
                target.rotation = Quaternion.LookRotation(targetDirection);
                transform.rotation = Quaternion.RotateTowards(transform.rotation, target.rotation, Time.deltaTime);
            }
        }
    }

The transform is the player and he is start walking forward "Walk Forward", but he never rotate towards the target. he keep moving straight walking forward.

The "Walk Forward" is a trigger parameter i'm using in my animator controller on a transition to a state with HumanoidWalk animation.

The question is why the transform is not rotating towards the target and keep walking straight forward instead ?

Maybe you're overriding the rotations with the animator.SetTrigger? Idk too much of animation, but It seems odd to me that animator.SetTrigger is called in every frame and after that there's no flag raised to stop calling it over and over. From what I've seen in the docs , this trigger gets called after a certain event (ie press a key) but not in every frame. Hope it helps :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM