0
\$\begingroup\$
var angle = temp.transform.rotation.eulerAngles;
            angle.y = 90;

temp.transform.rotation = Quaternion.Euler (angle);

I have tried this and some other variation to change the rotation of the instantiated prefab but it does not work at all.

How can I fix this?

\$\endgroup\$
5
  • \$\begingroup\$ What does it do? Do you have the script attached? \$\endgroup\$
    – Savlon
    Commented Oct 10, 2014 at 13:50
  • \$\begingroup\$ Yes I have attached the script, prefabs are being instantiated but not rotated as I need them to \$\endgroup\$
    – systemdebt
    Commented Oct 10, 2014 at 14:07
  • \$\begingroup\$ What is the temp variable? \$\endgroup\$
    – Savlon
    Commented Oct 10, 2014 at 14:23
  • \$\begingroup\$ It's the Gameobject in which reference to instantiated prefab is stored. \$\endgroup\$
    – systemdebt
    Commented Oct 10, 2014 at 15:29
  • \$\begingroup\$ Have you tried just attaching a script to the prefab and sending a message to it to rotate? \$\endgroup\$
    – Savlon
    Commented Oct 10, 2014 at 23:47

1 Answer 1

1
\$\begingroup\$

You could create an already rotated object by using

GameObject instance = GameObject.Instantiate (prefab, position, rotation)

where rotation is a Quaternion you compute earlier in the code like this:

Quaternion rotation = Quaternion.Euler (0, 90, 0)
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .