gpt4 book ai didi

Can't play and change the animator animations in unity(无法统一播放和更改动画师动画)

转载 作者:bug小助手 更新时间:2023-10-25 22:18:19 24 4
gpt4 key购买 nike



i have cone and it has mesh collider, it is trigger, i have one animator with two animations, 1 st animation name is "Animation1" and the second animation name is "Animation2", in animator parameters i have boolean with name Playanimation and in transition condition is true. I want to change the condition to false to play second animation, when player touch the cone collider. And here is the script, that i attach to cone. But the script doesn't work, unity always plays the first animation1. I want to play animation2 in animator when player touch with clone collider and again animation 1 if player doesn't touch the collider.

我有圆锥体,它有网格碰撞器,它是触发器,我有一个动画师有两个动画,第一个动画名称是“Animation1”,第二个动画名称是“Animation2”,在动画参数中,我有一个布尔值,名称为PlayAnimation,在过渡条件下为真。当玩家触摸锥体碰撞器时,我想将条件更改为FALSE以播放第二个动画。这是我附在CONE上的剧本。但是剧本不起作用,Unity总是播放第一个动画1。我想在动画师中播放动画2,当玩家接触克隆对撞机时,如果玩家没有接触到对撞机,再播放动画1。


using UnityEngine;

public class ConeColliderController : MonoBehaviour
{
private Animator animator;

private void Start()
{
// Get a reference to the Animator component on the object with your animations
animator = GetComponentInParent<Animator>();
}

private void OnTriggerEnter(Collider other)
{
// Check if the colliding object is the player
if (other.CompareTag("Player"))
{
// Change the condition to false in the Animator
animator.SetBool("Playanimation", false);
}
}
}

更多回答

Then you need to debug whats going on

然后,您需要调试正在发生的事情

优秀答案推荐
更多回答

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com