How to rotate an Instantiated object?

Hello i need help rotating lasers becuase when my player rotates, the laser does not face the direction the player is shooting. Here's some of my script right now -

var ourRotation : int = transform.rotation.y;

if(Input.GetButtonDown("Jump"))
{

//create our laser

var laser0 = Instantiate(laserPrefab, transform.Find("spawn").transform.position,Quaternion.identity);

//add force to our laser

laser0.rigidbody.AddForce( transform.forward * force);

//rotate our laser

laser0.Rotate(0, ourRotation, 0);

}

Hullo Game hound,

It's hard to tell exactly how your laser prefabs work, but looking at your code, there are a couple of things you could try changing. For starters, I'd make `var ourRotation` a `float` instead of an `int`, for the sake of precision. I don't see why you'd even need to use an extra variable for rotation in this case, the line

    var laser0 = Instantiate(
laserPrefab, transform.Find("spawn").transform.position,Quaternion.identity);

could be re-written as

    var laser0 = Instantiate(
laserPrefab, transform.Find("spawn").transform.position,transform.rotation);

Possibly, the reason your code didn't work, was that `laser0.Rotate` should be `laser0.transform.Rotate`. I don't think that should even compile without error. Again, I don't know how your lasers work exactly, but you can prolly leave that bit out now, making the final result...

if(Input.GetButtonDown("Jump")) 
{

var laser0 : GameObject = Instantiate(laserPrefab,  transform.Find("spawn").transform.position,transform.rotation);

laser0.rigidbody.AddForce( transform.forward * force);

}

Hope this helps!