【发布时间】:2017-10-11 15:35:03
【问题描述】:
我是Unity的新用户,我正在尝试制作一个小2D平板电脑。 我可以控制我的播放器,但我的跳跃有点问题。
我在动画师中使用触发器制作了它,它可以工作,但是我想在玩家接触地面时停止动画。
最好的办法是保持最后一次跳跃的帧准备,直到玩家接触地面,然后停止。
我有一个 gameObjet 上的 collider2D,它使用以下代码连接到玩家:
void Start()
{
Audio = GetComponent<AudioSource>();
Anim = transform.parent.GetComponent<Animator>();
}
void OnTriggerEnter2D (Collider2D col)
{
if (col.gameObject.tag == "Sol" || col.gameObject.tag == "Plateforme")
{
Anim.SetTrigger("stopJump");
transform.parent.GetComponent<playerController>().isGrounded = true;
Audio.pitch = 0.7f;
Audio.volume = 0.7f;
Audio.PlayOneShot(soundGround);
}
}
我的动画师在 'jump' 'idle' 和 run 之间有一个过渡 'stopJump'。这是正确的做法吗? see my animator here
动画 Jump 不想在结束帧之前停止。如果我禁用“有退出时间”,跳跃停止太早...... 触发器'stopJump'没有优先级...
谢谢!
【问题讨论】: