• Hey! Guest! The 37th GMC Jam will take place between May 28th, 12:00 UTC and June 1st, 12:00 UTC. Why not join in! Click here to find out more!

GMS 2 [Solved] How can I make collisions

DotCodes

Member
Hello!
I am making a game and I was wondering how to code a collision system with that is compatible with the code for my Movement system. Any help would be greatly appreciated!
Code:
hInput = keyboard_check(ord("D")) - keyboard_check(ord("A"));
vInput = keyboard_check(ord("S")) - keyboard_check(ord("W"));

if(hInput != 0 or vInput != 0){
    dir = point_direction(0, 0, hInput, vInput);
    moveX = lengthdir_x (spd, dir)
    moveY = lengthdir_y (spd, dir)

    x += moveX;
    y += moveY;
 

3dgeminis

Member
Replace the 2 last lines:
Code:
if !place_meeting(x+moveX, y, obj_wall) {x += moveX;}
if !place_meeting(x, y+moveY, obj_wall) {y += moveY;}
 
Top