• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Don't teleport into objects!

R

Rango

Guest
Hey!

I'm making a Top Down Shooter where you can teleport towards the mouse, the player just jumps to the postion of obj_cursor. If I click on obj_wall the player teleports into it and gets stuck. Is there a way how to not teleport into it? Like if you click on it it teleports beside the wall or basically just doesn't teleport at all?

Thanks :)
 

Niels

Member
Just check for a collision with a wall on the position of mouse x and y when activating teleport

Example:

When mouseclick {
If !collision_point( mouse_x, mouse_y, obj_wall, false, true) {
Obj_player.x = mouse_x
Obj_player.y = mouse_y
}
}
 
Just check for a collision with a wall on the position of mouse x and y when activating teleport

Example:

When mouseclick {
If !collision_point( mouse_x, mouse_y, obj_wall, false, true) {
Obj_player.x = mouse_x
Obj_player.y = mouse_y
}
}
Wouldn't they want to use:

if mouse click
{
if !place_meeting( mouse_x, mouse_y, obj_wall)
{
Obj_player.x = mouse_x;
Obj_player.y = mouse_y;
}
}

As collision_point would only take into account whether mouse_x / mouse_y was in collision with an object, and not include the dimensions of the object that they want to check for collision with the wall...??
 
Top