- Home /
C#: Change transform.position in code
I'm currently trying to replace some animations I was never that happy with (built in Unity) with iTweens... I want to take the gameObject's transform.position and change it a bit, and then save that as a new transform.
But I keep running into "error CS0119: Expression denotes a variable', where a
method group' was expected"
It hits on line 23 in my code, which is completely blank, so I suspect it means where DrawerOutPos.position = tempvect();
Anyway... here's my code:
void Start () {
DrawerInPos = gameObject.transform; Vector3 tempvect = new Vector3(); tempvect.x = gameObject.transform.position.x; tempvect.y = gameObject.transform.position.y+0.4f; tempvect.z = gameObject.transform.position.z; DrawerOutPos.position = tempvect(); }
Answer by Luci85 · Jul 03, 2012 at 08:37 PM
Try that:
Vector3 tempvect = new Vector3(gameObject.transform.position.x, transform.position.y+0.4f, gameObject.transform.position.z);
DrawerOutPos.position = tempvect;
INullReferenceException UnityEngine.Transform.set_position (Vector3 value) (at C:/BuildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/Editor/UnityEngineTransform.cs:20) DrawerAnims.Start () (at Assets/Scripts/DrawerAnims.cs:20)
Line 20 is where "DrawerOutPos.position = tempvect;" is falling.
Your answer
Follow this Question
Related Questions
Locking gameobject to rotating floor 0 Answers
Check y transform. Or limit(stop). 0 Answers
placing an object to it's initital position after picked up. 0 Answers
Rotating a Vector3 in Instantiation 1 Answer
Multiple Cars not working 1 Answer