I’m instantiating a spaced row of bullets in front of a game object (rwf royal welsh fusilers). This works fine when the object is stationary, however when the object rotates the bullets instantiate on the world x axis not the local x axis of the game object. The y and z axis are fine. I’ve tried many variation on “transform.localRotation” and making the game objects rotation a variable to no avail. The question is- how to get the x axis of the row as it instantiates to match the x axis of the game object? I’m sure the answer is something simple that I’ve overlooked. Any Suggestions?
Thanks
var bullets : Rigidbody;
var sbt : float = .5;
var rwf : GameObject;
function Update ()
{
if(Input.GetKeyDown(KeyCode.Return)){
var pos : Vector3 = rwf.transform.position;
var i : int = 0;
for(i=0; i<=8; i++){
Instantiate(bullets, Vector3(pos.x+i-4*sbt, pos.y, pos.z-2), rwf.transform.rotation);
}
}
}