Don't teleport into objects!

Discussion in 'Programming' started by Rango, Aug 25, 2018.

  1. Rango

    Rango Member

    Aug 23, 2018

    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 :)
  2. Niels

    Niels Member

    Jun 22, 2016
    Just check for a collision with a wall on the position of mouse x and y when activating teleport


    When mouseclick {
    If !collision_point( mouse_x, mouse_y, obj_wall, false, true) {
    Obj_player.x = mouse_x
    Obj_player.y = mouse_y
  3. the_dude_abides

    the_dude_abides Member

    Jun 23, 2016
    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...??

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice