如何在所需位置切换动画
我正在创建我的第一个统一游戏,以学习其工作原理。游戏:玩家需要通过跳过怪物来避免怪物。如果它与怪物相撞,则玩家死亡,石头拇指动画出现在其位置。 有一个动画师负责站立/步行动画
private Animator isWalkingAnimator;
isWalkingAnimator = GetComponent<Animator>(); //this is in Awake
void AnimatePlayer(string animatorName) //is called from Update
{
Vector2 scale = transform.localScale;
scale.x = playerWalkingState;
if(playerWalkingState != 0)//walk
{
isWalkingAnimator.SetBool(animatorName, true);
prevWalkingState = playerWalkingState;
}
else//stand
{
isWalkingAnimator.SetBool(animatorName, false);
scale.x = prevWalkingState;
}
transform.localScale = scale;
}
我的播放器脚本在private void oncollisionEnter2d(Collision2D Collision)
中, if(collision.gameobject.comparetag(“敌人”))
我希望iswalkingAnimator
显示Thum Stone Animation
我尝试了以下操作:iswalkingAnimator.setbool(setbool)(” isdead”,false);
,但什么也没发生
I'm creating my first unity game for learning how it works. the game: a player needs to avoid monsters by jumping over them. if it collides with a monster, the player dies and a stone thumb animation appear in its place.
My Player script has an Animator responsible for stand/walk animation like this
private Animator isWalkingAnimator;
isWalkingAnimator = GetComponent<Animator>(); //this is in Awake
void AnimatePlayer(string animatorName) //is called from Update
{
Vector2 scale = transform.localScale;
scale.x = playerWalkingState;
if(playerWalkingState != 0)//walk
{
isWalkingAnimator.SetBool(animatorName, true);
prevWalkingState = playerWalkingState;
}
else//stand
{
isWalkingAnimator.SetBool(animatorName, false);
scale.x = prevWalkingState;
}
transform.localScale = scale;
}
in private void OnCollisionEnter2D(Collision2D collision)
If the user collides with an enemyif (collision.gameObject.CompareTag("Enemy"))
I wish isWalkingAnimator
to show the thum stone animation
I've tried this: isWalkingAnimator.SetBool("isDead", false);
but nothing happens
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论