• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

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