unity3D动画控制问题?

我要通过物体移动的位置来控制动画,但不知道为什么不行
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);
}
}
}
或者说,有什么代码可以不断的获得物体目前移动的位置?
问题已解决

精慕HU
浏览 684回答 1
1回答

翻阅古今

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;}}我的给你参考,可以用
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Unity 3D