# movement

ya know the movement where the body is facing the mouse while the legs are facing the movement direction?

well im trying to figure that out, but i keep ending up with the weirdest outcomes
i’ve deleted everything about it and just put some basic movement to work on some other things

so any advice on the movement?

i havent been able to find any tutorials

Have you ever studied polar coordinates, or trigonometry?

You have the legs move separately, and the body shares the legs’ position, except is rotated by a certain number of degrees. To find the degrees, do the following:

arctan((mouse_y_position - body_y_position)/(mouse_x_position - body_x_position))

You probably know arctan as tan^-1, if you know it at all.

i have the body facing the mouse fine, that was easy, its getting the legs under him and having them face the movement direction

ive never studied trig
i wanted to, but there was a mishap at school and i had to leave

anyway
legs
confusion

arctan

(see my sig)
lol

In that case:

if (mouse_x_position - legs_x_position > 0)
{
legs_direction = right;
}
if (mouse_x_position - legs_x_position < 0)
{
legs_direction = left;
}

now if only GM would open
lol

Let me know if it works, or if you need anything else =P

will do
once it works
lol

totally forgot to mention that its a top down

… Um.

Why would you make the body face the mouse, but not the legs, in a top-down?

they have that movement system
its weird and i want to toy with it

So I played it a bit, and I actually like the way they did it. I think it’s completely unnecessary, but they make it look alright.

I don’t see what you don’t get about how they did it, though. If you press up, turn the legs up. If you press left, turn them left. The position of the legs and body stay the same.

im having a brain fart at getting the legs to be under the body and face the movement direction

Legs under body just means you put them on different depths. I don’t remember how to do that, and I don’t have GM on this computer, but it’s in the help files. Look around for “instance depth” or something like that.

To make them face the movement direction, just do an if thingy:

``````x_speed = 0;
y_speed = 0;
if (key_pressed == w)
{
rotate = 90;
y_speed -= 5;
}
if (key_pressed == s)
{
rotate = 270;
y_speed += 5;
}
if (key_pressed ==a)
{
rotate = 180;
x_speed -= 5;
}
if (key_pressed == d)
{
rotate = 0;
x_speed += 5;
}``````

I dunno if rotation’s in degrees, but you should be able to figure that out…

sweeeet
seems like it would work

i really need to stop being in a fog
lol

thanks!
once i get it open i’ll see if it works =D

edit*

im just not in the groove, lol
i cant get it to add the object legs!
xD

am i on crack?

edit*

so i got the legs under him…
and they just keep running

atleast theyre following him xD

edit*

now they only apear once i start moving, always facing the right
and not moving at all

edit*

now thye face the right direction
they just dont move

edit*

WORKS!
completely! =D

thanks much Timmeh!

My pleasure!

Let me know if you need anything else.