Where the bullet spawns when I shoot
嗨,由于某些原因,我的子弹不会在我告诉它的地方产生。 产卵点位于我的枪管末端,当我实例化子弹时我采取其变换位置和旋转,但它产生的高于枪(更高的方式)。 这是我的代码:
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");
}
}
帮助:)
答案 0 :(得分:0)
可能会发生,子弹的起源不在模型的中间。