我有一个模型,我已经有了漫步和空闲动画,但不知怎的,我永远无法获得“跳跃”。我真的无法理解为什么?
我尝试了触发器,但仍然没有好处。
这是我模型中名为“AnimatePlayer”的代码:
#pragma strict
var body : Transform; //Tranform the armature of the player model
var mousexThreshold = 0.2; //Number of units for the mouse to move on x-axis
//Settings for the Upper Body rotation
var sensitivityY = 15F;
var minimumY = -60F;
var maximumY = 60F;
var rotationY = 0F;
function Update () {
if( transform.rotation.eulerAngles.y == 270 ) { // Left rotation
if(Input.GetAxis("Horizontal") > 0) //Walk Backwards
{
animation["Walk"].speed = -2;
animation.Play("Walk");
}
else if(Input.GetAxis("Horizontal") < 0) //Walk Forward
{
animation["Walk"].speed = 2;
animation.Play("Walk");
}
else if(Input.GetAxis("Horizontal") == 0)
{
animation.Play("Idle");
}
}
if( transform.rotation.eulerAngles.y == 90.00001 ) { // Right rotation
if(Input.GetAxis("Horizontal") > 0) //Walk Forward
{
animation["Walk"].speed = 2;
animation.Play("Walk");
}
else if(Input.GetAxis("Horizontal") < 0) //Walk Backwards
{
animation["Walk"].speed = -2;
animation.Play("Walk");
}
else if(Input.GetAxis("Horizontal") == 0) //Return to standing posture
{
animation.Play("Idle");
}
}
// Transform the rotation of the player when mouse moves on the x-axis
var mousex : float = Input.GetAxis ("Mouse X");
if (mousex > mousexThreshold) //Player faces right
{
transform.forward = new Vector3(1f, 0f, 0f);
}
else if (mousex < -mousexThreshold) //Player faces left
{
transform.forward = new Vector3(-1f, 0f, 0f);
}
}
function LateUpdate(){
// will make the upper body of the model to be rotatable along the y-axis
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
body.transform.localEulerAngles = new Vector3(0, rotationY, 0);
}
function OnTriggerEnter(other : Collider){
if(other.tag == "Ground"){
animation.Play("Idle");
}else if(other.tag == "Platform"){
animation.Play("Idle");
}
}
function OnTriggerExit(other : Collider){
if(other.tag == "Ground"){
animation.Play("Jump");
}else if(other.tag == "Platform"){
animation.Play("Jump");
}
}
正如你所看到的,我有一个触发器来播放“跳转”动画,但仍然没有。是因为我有很多动画同时播放吗?