出现在目的地的Unity 2D c#对象不是" Lerping"

时间:2014-09-04 18:40:17

标签: c# unity3d

我不明白为什么这个脚本会导致对象跳转到目的地而不是平稳地移动到目的地?

    public GameObject Hand;
public GameObject projectile;

void OnCollisionStay2D (Collision2D coll)
{
    if (Input.GetKeyDown (KeyCode.E)) {    
        if (coll.gameObject.tag == "Pickup") {
            if (Hand.transform.childCount < 1) {
                coll.gameObject.transform.position = Hand.transform.position;
                coll.gameObject.transform.parent = Hand.transform;
                projectile = coll.gameObject;
                //coll.gameObject.name = "Projectile";
            }
        }
    }
}

void Update () 
{
        if (Input.GetMouseButtonDown (1)) {
                if (Hand.transform.childCount == 1) {
                    projectile.transform.rotation = Hand.transform.rotation;
                    projectile.gameObject.transform.parent = null;
                    float shotDistance = 3;
                    float time = 3;                         
                    projectile.transform.Translate(Vector3.Lerp (Hand.transform.position,Vector3.up * shotDistance,time));      
        }
    }
}

非常感谢任何帮助,

谢谢,

1 个答案:

答案 0 :(得分:1)

如果您查看Vector3.Lerp的签名,您会注意到您为浮点数传递的值为3。

浮动应该是0-1,0.5是中途。