Gasil
Member
This is the code I'm using for movement:
dir = 0;
dirFinal = 0;
dirX = x
dirY = y
Vel = 5 //Movement speed.
Vel2 = 3 //Rotation speed
Could you help me to code some collisions using an object and a simple function like place_free or place_meeting? I tried it myself but I was just making my obj player to get stuck in the object; the lengthdir function is messing me up.
Thank you.
dir = 0;
dirFinal = 0;
dirX = x
dirY = y
Vel = 5 //Movement speed.
Vel2 = 3 //Rotation speed
Code:
if(keyboard_check(ord("W")))
{
var xx = lengthdir_x(vel, dirFinal);
var yy = lengthdir_y(vel, dirFinal);
dirX += xx;
dirY += yy;
}
if(keyboard_check(ord("S")))
{
var xx = lengthdir_x(vel, dirFinal);
var yy = lengthdir_y(vel, dirFinal);
dirX -= xx;
dirY -= yy;
}
if(keyboard_check(ord("D")))
{
dirFinal -= vel2;
}
if(keyboard_check(ord("A")))
{
dirFinal += vel2;
}
dir = lerp(dir, dirFinal, 0.2);
x = lerp(x, dirX, 0.5);
y = lerp(y, dirY, 0.5);
Thank you.