• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Move direction

D

Distorted

Guest
I'm making a top-down game in which my player is facing to the top of the screen at all times, and instead the floor is rotating when I move the mouse. is there any way I could make my character move forwards, backwards, left and right in the direction which my sprite is facing?

the direction stays the same while the view_angle is rotating, I tried fixing this by typing "direction=view_angle" but that doesn't seem to work :/
 

obscene

Member
Probably going to be as simple as moving your player in the direction of view_angle+90 or something like that.
 
J

Joe134

Guest
Dunno if you did this or not, but you have to specify which view angle, ie. view_angle[0]
 
D

Distorted

Guest
Probably going to be as simple as moving your player in the direction of view_angle+90 or something like that.
I already did, but that's only moving my player in the right direction. I'm still going the same direction wherever I'm facing :/
 

Nux

GameMaker Staff
GameMaker Dev.
are you using hspeed/custom variables or simply speed?

if you're using hspeed, try use speed.

alternatively, if you're using custom variables, you should set them depending on the vector of speed, in other words, set then depending on the angle:
Code:
spd = 5; // pixels per frame
hsp = lengthdir_x(spd,direction);
vsp = lengthdir_y(spd,direction);
EDIT::
I already did, but that's only moving my player in the right direction. I'm still going the same direction wherever I'm facing :/
Yes. This is what happens, since you are changing the view angle and direction by the same ammount, therefore it gives the illusion you are moving constantly right, but you're not.

Remove the code that changes the view angle, and you'll soon find that you'll be moving in a line depending on direction.
 
Last edited:
D

Distorted

Guest
Dunno if you did this or not, but you have to specify which view angle, ie. view_angle[0]
yes :(
are you using hspeed/custom variables or simply speed?

if you're using hspeed, try use speed.

alternatively, if you're using custom variables, you should set them depending on the vector of speed, in other words, set then depending on the angle:
Code:
spd = 5; // pixels per frame
hsp = lengthdir_x(spd,direction);
vsp = lengthdir_y(spd,direction);
EDIT::

Yes. This is what happens, since you are changing the view angle and direction by the same ammount, therefore it gives the illusion you are moving constantly right, but you're not.

Remove the code that changes the view angle, and you'll soon find that you'll be moving in a line depending on direction.
You're amazing, thanks ^^
 
Top