I am new to unity and i was wanting to know how i can change a objects position and angles and stuff like that in a c# script. I exported the object from blender as .3ds. The objects name is sphere.3ds. please show and explain code.
A quick and easy way to do this would be just to pass in the object as a variable. Creating a public GameObject variable in a script will allow an object to be handed to it from the Unity interface.
Then when you go back into unity you can see a new box appeared in the script module. You can then drag the object you want to manipulate into that box that says To then manipulate that object's position, you can just use its transform and do as you please. It's the object's transform variable which determines its position, rotation, etc.
Also, the transform variable already supplies you with useful functions that you can mess around with, like Translate and RotateAround. To rotate an object around an axis, use
The first parameter is the position of the rotation, the second is the axis you want to rotate around, say up, left, right, etc.. And the third is the amount you want to rotate it by. |
|||||||||||||||||||||
|