Question by
MotherShipIL · Nov 18, 2015 at 08:34 PM ·
transformpositioning
Syntax error when i try to simply modify transform position
transform.position = new Vector3(0, 0, 0);
I've tried this ^ to move my gameobject to certain position, but for some reason i get and error- unexpected symbol `=' in class, struct or interface declaration.... To make ensure this is not a problem on my end Ive tried to implent this line in other scripts, among them were scripts from official unity tutorial (roguelike 2d game)
any thoughts on what might be the problem?
Comment
well i kind of figured it out... i need to declare a vector 3, set my position values to it, modify it to be the one i want, and then set it back on my transform
looks like this-
Vector3 myPosition = transform.position;
myPosition.x = 1;
transform.position = myPosition;
still don't understand why the one liner wont work...