我要通过物体移动的位置来控制动画,但不知道为什么不行using UnityEngine;using System.Collections;public class AIhornAnimation : MonoBehaviour {public Animator anim;private Vector3 Player;private Vector3 AIHorn;void Start () {Player = GameObject.Find("Player").transform.position;AIHorn = GameObject.Find("AIhorn").transform.position;anim = GetComponent<Animator> ();}void Update () {if (Player.x > AIHorn.x) {anim.SetBool("MoveRight",true);anim.SetBool("MoveLeft",false);}if (Player.x < AIHorn.x) {anim.SetBool("MoveRight",false);anim.SetBool("MoveLeft",true);}}}或者说,有什么代码可以不断的获得物体目前移动的位置?问题已解决
1 回答
翻阅古今
TA贡献1780条经验 获得超5个赞
void PlayerState (CharacterState state)
{
playerState = state;
switch (state) {
case CharacterState.Forward:
animation.CrossFade ("Run");
break;
case CharacterState.Back:
animation.CrossFade("B_Run");
break;
case CharacterState.Left:
animation.CrossFade("L_Run");
break;
case CharacterState.Right:
animation.CrossFade("R_Run");
break;
default:
animation.CrossFade ("Idle");
break;
}
}
我的给你参考,可以用
- 1 回答
- 0 关注
- 683 浏览
添加回答
举报
0/150
提交
取消