我从我的预制“子弹”中实例化刚体“克隆”以在我的项目中拍摄它们。我想获得我射击的每颗子弹(每一个实例)的速度。在下面我的代码示例中:
public GameObject throwstart;
public Rigidbody Clone;
public float bulletVelocity { get; set; } = 1;
...
...
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
Rigidbody Clone2;
Clone2 = Instantiate(Clone, throwstart.transform.position, throwstart.transform.rotation);
Clone2.GetComponent<Rigidbody>().AddForce(Clone2.transform.forward * bulletVelocity, ForceMode.Impulse);
Debug.Log("Velocity Clone Instanz: " + Clone2.mass);
Debug.Log("Velocity Clone Instanz: " + Clone2.velocity);
}
}
通过上面的代码,我得到了我的预制件的速度/质量(但速度总是(0、0、0),质量是正确的)。我做错了什么,如何获得每个实例化子弹的速度?