D
Den
Guest
I'm trying to make a Nuclear Throne type movement (The player faces the mouse and switches the direction it's facing based on where the mouse is) but I can't figure out how to fix this thing that's happening.
The system works fine when not moving and when moving to the right but when the player moves to the left
it faces away from the mouse like it's inverted or something.
Anyone know what could be causing this?? it's the first time I have ever done this type of movement so I'm
kinda stuck.
Here's what I have:
The system works fine when not moving and when moving to the right but when the player moves to the left
it faces away from the mouse like it's inverted or something.
Anyone know what could be causing this?? it's the first time I have ever done this type of movement so I'm
kinda stuck.
Here's what I have:
Code:
// Get the axis
var xaxis = (right_key - left_key);
var yaxis = (down_key - up_key);
// Get direction
var dir = point_direction(0, 0, xaxis, yaxis);
// Get the length
if (xaxis == 0 and yaxis == 0) {
len = 0;
} else {
len = spd;
}
// Get the hspd and vspd
hspd = lengthdir_x(len, dir);
vspd = lengthdir_y(len, dir);
// Move
phy_position_x += hspd;
phy_position_y += vspd;
// Control the sprite
image_speed = .6;
if(length == 0) sprite_index = spr_idle;
//Face the mouse
look_at = point_direction(x,y,mouse_x,mouse_y);
//Flip the sprite
if(mouse_x > x) {
image_xscale = 1;
}else {
image_xscale = -1;
}
// Horizontal sprites
if(hspd > 0) {
sprite_index = spr_goblinRun_right;
}else if(hspd < 0){
sprite_index = spr_goblinRun_left;
}