Game Development Community

Simply changing an objects position... [RESOLVED]

by Randy Lutcavich · in Torque X 2D · 08/20/2009 (1:48 am) · 2 replies

How can I move my player (without using the default movement component)?

I'm trying to make it so pressing 'W' will move my player exactly 10 pixels up.

I can't figure anything out using the default movement component, everything seems physics based.

I tried just grabbing the player's position and changing that but it is read only.

#1
08/20/2009 (2:10 am)
Randy,

I simply tried both of the following within the ProcessTick of the default Movement component and they both worked to set the position.

_sceneObject.SetPosition(new Vector2(0, 0), true);

or 

_sceneObject.Position = new Vector2(0,0);

The Vector2 will be the postion that you are moving your object to.
#2
08/20/2009 (2:15 am)
Both those work, thanks!

My problem either lied in the fact that I was attempting to change just the x value (_sceneObject.Position.X) or the fact that I wasn't creating a new Vector2.

Either way, thanks again Jake!