K
KuluGary
Guest
Hello! I'm not very fluent with GM:S at the moment but I'm eager to learn. I have used other, more simple, game engines but I want the skills that come from knowing how to code things.
As such, I tried following some tutorials on how to do both Point and click moement (in all directions) and Sidescroller movement and trying to mesh up at the best of my abilities.
This is the movement engine I have atm. I made so I can move horizontally towards the direction clicked thanks to a cursor obj, but my problem now is that while I have vertical collisions, I can't seem to make horizontal collisions work.
I, again, am at a really novice level but any hints on how to solve this would be greatly appreciated.
Thanks in advance!
As such, I tried following some tutorials on how to do both Point and click moement (in all directions) and Sidescroller movement and trying to mesh up at the best of my abilities.
This is the movement engine I have atm. I made so I can move horizontally towards the direction clicked thanks to a cursor obj, but my problem now is that while I have vertical collisions, I can't seem to make horizontal collisions work.
Code:
///Get the players input
key_move = mouse_check_button(mb_left);
//React to inputs
move = key_move;
mouseDistance = point_distance(x,y, obj_mouseClick.x, y);
hsp = move_towards_point(obj_mouseClick.x,y,min(4, mouseDistance));
if (vsp < 10) vsp += grav;
if(place_meeting(x,y+1,obj_solid))
{
vsp = 0
}
// Horizontal collision
if(place_meeting(x+hsp,y,obj_solid))
{
while(!place_meeting(x+sign(hsp),y,obj_solid))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
// Vertical collision
if(place_meeting(x,y+vsp,obj_solid))
{
while(!place_meeting(x,y+sign(vsp),obj_solid))
{
y += sign(vsp);
}
vsp = 0;
}
y += vsp;
Thanks in advance!