I have had this problem a couple of times and i always forget how i fix it.What i am trying to do is make a bullet spawn in front of the barrel and add a force to move it forward and no matter what i do the bullet just moves to the left of the gun... Can someone please explain to me(EXPLAIN TO ME) how to fix this so i will always have a reference to solve this problem.
oh yea the code...
var bullettype : Transform;
var spawnspot : Transform;
var bulletspeed : float = 500.0;
function Update () {
if(Input.GetButtonUp("Fire1")){
var shot = Instantiate(bullettype,spawnspot.transform.position,spawnspot.transform.rotation);
shot.rigidbody.AddForce(transform.forward * bulletspeed);
Debug.Log("Fired");
}
Please format your code appropriately when posting it (the 101010 button in the formatting box) as it makes it easier for people to read.
– Chris-D