简体   繁体   English

为什么物体从不向目标旋转?

[英]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. “向前走”是我在动画控制器中使用的触发参数,用于转换到具有 HumanoidWalk 动画的状态。

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?也许您正在使用 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. Idk 动画太多了,但对我来说似乎很奇怪 animator.SetTrigger 在每一帧中都被调用,之后没有任何标志来停止一遍又一遍地调用它。 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 :)希望能帮助到你 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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