Instantiating an object with specific transform positions and rotations

I am trying to instantiate an object at specific positions and rotations, and I can't make it work:

var rotationParent : GameObject;
var playerLocation : GameObject;

function Awake () {

rotationParent = GameObject.Find("CamAnimator");
playerLocation = GameObject.Find("Fire Point");

function Update () {

function makeObject (){
Instantiate (bulletParticle, (playerLocation.transform.position.x, playerLocation.transform.position.y,playerLocation.transform.position.z), (playerLocation.transform.rotation.x, rotationParent.transform.rotation.y, playerLocation.transform.rotation.z));

Please note I am trying to instantiate the object at playerLocation's XYZ position and XZ rotation, but use rotationParent's Y axis; this is critical to what I am trying to do.

At any rate, this doesn't work the way I expected it to, I get the following error in the Console:

Assets/Scripts/FireControl.js(57,82): BCE0044: expecting ), found ','.

Could someone please help me figure out what I am doing incorrectly? Thanks a lot.

Maybe try it like this:

Instantiate (bulletParticle, new Vector3(playerLocation.transform.position.x, playerLocation.transform.position.y,playerLocation.transform.position.z), Quaternion.Euler(playerLocation.transform.rotation.x, rotationParent.transform.rotation.y, playerLocation.transform.rotation.z));

  • Add the "new Vector3" to your script (or just Vector3, i forgot about javascript)
  • Add the "Quaternion.Euler" to your rotations so it gets delivered back as Quaternion

I don't know if there is a easier solution and if this really works 100% but at least i think it should work this way.

Hope this helps.

Instantiate (original : Object, position : Vector3, rotation : Quaternion)

This is the signature of this function. To instantiate an object in player place just use

Instantiate ( bulletParticle, playerLocation.transform.position, playerLocation.transform.roation);

You can tweak your rotation or position but you have to provide Vector3 in case position and quaternion in case of rotation.