[英]Unity 2D c# Object appearing at destination not “Lerping”
我不明白為什么這個腳本會導致對象跳到目的地而不是平穩地移動到目的地?
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));
}
}
}
任何幫助,我們將不勝感激,
謝謝,
如果查看Vector3.Lerp的簽名,您會注意到您為浮點數傳遞了3值。
浮點數應在0-1,0.5中間。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.