Hi, I’m trying to transform position of object in runtime, when I click on it, by this line
transform.position = new Vector3(20F,0F,0F);
or
transform.localPosition = new Vector3(transform.localScale.x,5.0F,transform.localScale.y);
I try with diferent parameters and every time object became transform in this same direction whatever I changed. For example
new Vector3(20F,0F,0F);
new Vector3(0F,20F,0F);
new Vector3(0F,0F,20F);
all these vectors creates the same action on my object.
I have also question how to transform the object to make it back to starting position.
I don’t know about your first question (maybe try to be a bit more specific), but if you want to know how to set an original position, this should do it:
public class TPCamera : MonoBehaviour
{
Transform CurrentPos;
void Start()
{
CurrentPos = GameObject.transform;
}
}
Note: The gameobject is the gameobject you want to transform, so in the update(), you then can transform the object to ‘CurrentPos’, what is the original position. And also, if you want extra information about vector3, I recommend taking a look at this tutorial, and inside monodevelop, you could also select ‘Vector3’, and the press the CTRL-key and ’ at the same time. Best of luck!