P
Paturicko
Guest
I recently started experimenting with motion_add because i find 8 directional movement with motion_add to be more smoother and less rigid. It works great but when I hit a corner at an angle the player gets stuck. This doesn't happen when I use lengthdir instead but i want to keep the smooth movement for keyboard inputs.
Sometimes when I'm stuck i build up speed and teleport to another location or the game stops reading my inputs. Can someone help?
Sometimes when I'm stuck i build up speed and teleport to another location or the game stops reading my inputs. Can someone help?
Code:
///input_move()
speed = clamp(speed, 0, maxspd);
if (gamepad_is_connected(0))
{
//Get Direction
var axislh = gamepad_axis_value(0,gp_axislh);
var axislv = gamepad_axis_value(0,gp_axislv);
dir = point_direction(0, 0, axislh, axislv);
//Movement && Deadzone
if (point_distance(0, 0, axislh, axislv) > 0.6)
{
obj_player.image_speed = 1;
motion_add(dir, accel);
dash_dir = dir;
}
else
{
obj_player.image_speed = 0;
obj_player.image_index = 0;
friction = decel;
}
}
//Collisions
if (place_meeting(x + hspeed, y, obj_wall))
{
while (!place_meeting(x + sign(hspeed), y, obj_wall))
{
x += sign(hspeed)
}
hspeed = 0;
}
if (place_meeting(x, y + vspeed, obj_wall))
{
while (!place_meeting(x, y + sign(vspeed), obj_wall))
{
y += sign(vspeed)
}
vspeed = 0;
}
Last edited by a moderator: