C# 为什么动画运行时间不会变短或变长?

C# 为什么动画运行时间不会变短或变长?,c#,animation,unity3d,C#,Animation,Unity3d,所以我有这个脚本,我试图让立方体跳到某个位置,部分原因是我想让立方体在向新的富足点移动时播放动画,我有下面的脚本,但由于某种原因动画不会变短或变长为什么?我做错了什么 using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMovement : MonoBehaviour { public float jumpMaxDistance; p

所以我有这个脚本,我试图让立方体跳到某个位置,部分原因是我想让立方体在向新的富足点移动时播放动画,我有下面的脚本,但由于某种原因动画不会变短或变长为什么?我做错了什么

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour {

    public float jumpMaxDistance;
    public float jumpSpeed;
    private float distance;

    private bool firstFrame = false;
    private Vector3 richPoint;
    public GameObject player;
    private Animation jump;

    void Start () {
        richPoint = transform.position;
        jump = player.GetComponent<Animation> ();

    }
    // Update is called once per frame
    void Update (){
        //Moves the player to the next point.
        if (firstFrame == true){
            if (transform.position != richPoint) {
                transform.position = Vector3.MoveTowards(transform.position, richPoint, Time.deltaTime * jumpSpeed);


            }//executes if the left click is pressed.
        }
        if (Input.GetMouseButtonDown (0)) {

            RaycastHit hit;

            //Get Ray from mouse position.
            Ray rayCast = Camera.main.ScreenPointToRay (Input.mousePosition);

            //Raycast and check if any object is hit.
            if (Physics.Raycast (rayCast, out hit, jumpMaxDistance)) 
                {
                //Raycast and check if any object is hit.
                if (hit.collider.CompareTag ("RichPoint"))
                {
                    richPoint = hit.collider.transform.position;
                    //This finds the distance between the player and richPoint.
                    float pBTime;
                    pBTime = distance / jumpSpeed;

                    //This plays the Animation depending on tha distance between transform.position and richPoint.
                    jump ["PlayerJump"].time = pBTime;
                    jump.Play ();

                    firstFrame = true;
                }
            }
        }
    }
}
使用系统集合;
使用System.Collections.Generic;
使用UnityEngine;
公共类玩家运动:单一行为{
公共浮标最大距离;
公众浮标跳跃速度;
私人浮动距离;
private bool firstFrame=false;
私有向量3 richPoint;
公共游戏对象玩家;
私人动画跳跃;
无效开始(){
richPoint=变换位置;
jump=player.GetComponent();
}
//每帧调用一次更新
无效更新(){
//将玩家移动到下一点。
if(firstFrame==true){
if(transform.position!=richPoint){
transform.position=Vector3.movetoward(transform.position、richPoint、Time.deltaTime*跳跃速度);
}//如果按下左键单击,则执行。
}
if(Input.GetMouseButtonDown(0)){
雷卡斯特击中;
//从鼠标位置获取光线。
光线投射=Camera.main.screenpointoray(输入.鼠标位置);
//光线投射并检查是否有物体被击中。
if(Physics.Raycast(Raycast,out-hit,jumpMaxDistance))
{
//光线投射并检查是否有物体被击中。
if(hit.collider.CompareTag(“RichPoint”))
{
richPoint=hit.collider.transform.position;
//这将查找玩家与richPoint之间的距离。
浮动时间;
pBTime=距离/跳跃速度;
//这将根据transform.position和richPoint之间的距离播放动画。
跳转[“PlayerJump”]。时间=pBTime;
跳。玩();
firstFrame=true;
}
}
}
}
}
使用动画状态。在这里