Hey so, I am currently struggling to set up my bullets travelling.
The ship that fires the bullets rotates and flys on X/Z axis which I realise is dumb. Either way, when I shoot my bullets they sometimes behave erratically.
The player has a location for where to spawn the bullets and this is the code to spawn the bullets.
void Shoot ()
{
var bulletToShoot = (GameObject)Instantiate (
bullet,
bulletSpawnLocation.position,
bulletSpawnLocation.rotation);
Destroy (bulletToShoot, 8.0f);
}
Next the bullet itself is a prefab with the bullet controller code as such:
void Update () {
transform.Rotate (0, player.transform.rotation.y, 0);
transform.Translate (0, 0, bulletSpeed * Time.deltaTime);
bullet.transform.position += transform.forward * Time.deltaTime * bulletSpeed;
}
I am unsure why it does this so any help would be appreciated.