O
O_Steven_007
Guest
So I've recently started getting into Gamemaker Studio 2 and was following videos by a youtuber called FunBox. I ran into some problems when play testing the code. Whenever I moved the player toward an object with collision the player would eventually get stuck and would not be able to move anymore.
Here is the code that I am using.
Here is the code that I am using.
Code:
/// Description
XAxis = keyboard_check(ord("D")) - keyboard_check(ord("A"));
YAxis = keyboard_check(ord("W")) - keyboard_check(ord("S"));
//Fixing Diagonal Speed Issue
var _direction = point_direction(0, 0, XAxis, YAxis);
var _lenght = Speed * (XAxis != 0|| YAxis != 0);
XAxis = lengthdir_x(_lenght, _direction);
YAxis = lengthdir_y(_lenght, _direction);
//Collision with SPECIFIC OBJECT
if (place_meeting(x+XAxis, y, obj_wall))
{
while (!place_meeting(x+sign(XAxis), y, obj_wall))
{
x += sign(XAxis);
}
XAxis = 0;
}
x += XAxis;
if (place_meeting(x+YAxis, y, obj_wall))
{
while (!place_meeting(x, y+sign(YAxis), obj_wall ))
{
y +=sign(YAxis);
}
YAxis = 0;
}
y += YAxis;