Just making a simple game where i am meant to instantiate a single rigidbody and make it travel forward from where it spawns in, instead it instantiates two rigidbodys and doesnt travel forward at all.
public Rigidbody laser;
public GameObject LaserSpawn;
private float fireRate = 0.65f;
private float shotReady;
private float velocity = 50f;
void Start () {
}
void Update () {
if(Input.GetKeyDown (KeyCode.Space) && Time.time > shotReady)
{
shotReady = Time.time + fireRate;
GameObject laserShot = Instantiate(laser, LaserSpawn.transform.position + LaserSpawn.transform.forward, laser.transform.rotation)as GameObject;
laserShot.rigidbody.AddForce(laserShot.transform.forward * velocity, ForceMode.Impulse);
}
}
}
any help will be much appreciated