嗨,由于某些原因,我的子弹不会在我告诉它的地方产卵。生成点在我的枪管末端,我在实例化子弹时采用它的变换位置和旋转,但它生成的位置比枪高(高得多)。这是我的代码:
Animation anim; // Gun animation when shooting
AudioSource gunSound; // Gun sound when firing
public Rigidbody bullet; // I get the rigidbody of the bullet that will be spawned
public Transform spawnPoint; // The position of where it is supposed to spawn
void Start()
{
anim = GetComponent<Animation>();
gunSound = GetComponent<AudioSource>();
}
void Update()
{
if (Input.GetButtonDown("Fire1")) // If the left mouse button is clicked
{
Rigidbody bulletInstance;
bulletInstance = Instantiate(bullet, spawnPoint.position, spawnPoint.rotation) as Rigidbody; // This is where I don't understand why?!?!
bulletInstance.AddForce(spawnPoint.forward * 1000f);
gunSound.Play();
//anim.Play("GunShot4");
}
}
帮助 :)