ThePlayerEden
Member
So I have this object that I plan to have "stick" to another object. Anyways, I want it to point in the direction of the cursor, I kind of have it down from following instructions from another post.
The only thing is that it just points in the four directions rather than staying and following the mouse cursor exactly, I basically want it to rotate as the mouse moves as a constant. I hope that makes sense.
Now I only have four-directional sprites for this, but I'll work on that later to make it look better, but I'm trying to have the mechanics down first at least. (I'm bad at art, so...)
Here's a copy of the code I have so far:
I only have a step event right now... Not sure what else I need for this yet.
Thanks in advance!
The only thing is that it just points in the four directions rather than staying and following the mouse cursor exactly, I basically want it to rotate as the mouse moves as a constant. I hope that makes sense.
Now I only have four-directional sprites for this, but I'll work on that later to make it look better, but I'm trying to have the mechanics down first at least. (I'm bad at art, so...)
Here's a copy of the code I have so far:
GML:
//STEP EVENT
var _player_riding = false;
with (obj_player)
{
if (player_transportation == move_states.RIDE)
{ // Check if the player is in ride state
_player_riding = true;
}
}
if _player_riding = true
{
//mouse directional rotation
var md = point_direction(x, y, mouse_x, mouse_y);
if (md >= 45 && md < 135) {
sprite_index = spr_gatty_turret_up;
} else if (md >= 135 && md < 225) {
sprite_index = spr_gatty_turret_left;
} else if (md >= 225 && md < 315) {
sprite_index = spr_gatty_turret_down;
} else {
sprite_index = spr_gatty_turret_right;
}
}
Thanks in advance!
Last edited: