# Make actor move one direction at a time.

Member Posts: 85
edited November -1
Hello, im in the process of making a game, and the actor is controlled by a virtual dpad.
i was wondering how to make it so the actor can only move 1 direction at a time

so Up, THEN down etc etc.

i dont want the player to have the abilty to press down up/left at the same time and have the actor traveling on an angle.
know what i mean?

• Member Posts: 3,470
Hehe, I wanted the diagonals... very hard to get them unless you make the d-pad buttons HUGE. You should be okay
• Member Posts: 85
thanks for the response POLYGAMe,
so your the one that made PRANKSTAR, ahahaa, that one scared the heck out of my 10 year old sister ahahha :P good one
• Member Posts: 1,400
Shouldn't be hard...

I'm thinking the math will look something like this:

`ceil(((VectorToAngle(joyCenter.x - joyTouch.x, joyCenter.y - joyTouch.y)-22.5)%360)/45)*45`

The order of "joyCenter" and "joyTouch" may need to be reversed in the VectorToAngle function. I'll test it on my lunch break...
• Member Posts: 3,470
rickyniko said:
thanks for the response POLYGAMe,
so your the one that made PRANKSTAR, ahahaa, that one scared the heck out of my 10 year old sister ahahha :P good one

Haha, hope she didn't drop your iPhone
• Member Posts: 85
POLYGAMe said:
Haha, hope she didn't drop your iPhone

haha, nah she threw it on the couch hahah
• Member Posts: 85
barkbark00 said:
Shouldn't be hard...

I'm thinking the math will look something like this:

`ceil(((VectorToAngle(joyCenter.x - joyTouch.x, joyCenter.y - joyTouch.y)-22.5)%360)/45)*45`

The order of "joyCenter" and "joyTouch" may need to be reversed in the VectorToAngle function. I'll test it on my lunch break...

thanks for that, ill try it out soon!

by the way, if you can, try help out with my other topic, its really recent so it should be up there)
• Member Posts: 1,400
I'll actually have to open GS to work that one out...maybe later.