- Home /
What variable type is this?
I need to rotate my object and then save the rotation in a variable, so I tried
RotationObject1 = Object1.transform.Rotate(Time.deltaTime, 1, 0);
But I need to declare the variable and I have no idea what type it is? (Transform, float, int, boolean or similar)
Answer by Tomer-Barkan · Oct 12, 2013 at 10:26 AM
Transform.Rotate does not return a variable. What it does is change the rotation of the transform, in your case it will chagne the rotation of Object1.
So Object1.transform will contain the new value after you run that command.
Btw, how do I instantiate with that then? Because if I instantiate with Object1, hit.point, Quaternion.identity it doesn't rotate as I wanted it to...
The 3rd variable is the rotation (Quaternion.identity in your case meens keep the rotation of the original object).
You can instantiate and then rotate:
GameObjec newObj = (GameObject)GameObject.Instantiate(Object1, hit.point, Quaternion.identity);
newObj.transform.Rotate(Time.deltaTime, 1, 0);
If you want to instantiate with the rotation right away, then you need to calculate the quaternion in advance, and pass it ins$$anonymous$$d of identity. You can use Quaternion.Euler to do that, read about it here: http://docs.unity3d.com/Documentation/ScriptReference/Quaternion.Euler.html
Your answer
![](https://koobas.hobune.stream/wayback/20220613115806im_/https://answers.unity.com/themes/thub/images/avi.jpg)