Drag And Drop How to make it impossible for the player to go through the obstacle?

Discussion in 'Programming' started by Dmitri Pisarenko, Jan 10, 2019.

  1. Dmitri Pisarenko

    Dmitri Pisarenko Member

    Joined:
    Jun 9, 2018
    Posts:
    13
    Hello!

    Imagine I have the player object and some obstacle object:

    [​IMG]

    When the player moves, it can get past the obstacle:

    [​IMG]

    [​IMG]

    I want make it impossible for the player to get past the obstacle:

    [​IMG]

    How can I achieve this result, i. e.

    • make it impossible for the player to pass the obstacle "underneath" it and
    • force the player to walk around the obstacle?

    What I tried:

    • Setting "solid" to true in object's properties (properties of the obstacle)
    • Checking "uses physics" in obstacle's properties
    • Checking "uses physics" of the room (with X and Y gravity equal to 0)

    None of this helped.

    Thanks in advance

    Dmitri Pisarenko
     
  2. Cowlord

    Cowlord Member

    Joined:
    Jun 29, 2017
    Posts:
    55
    Create a collision event between the wall and player and set the player values to:
    x = x - sprite_width / 2;

    By your picture it looks like the x, y of the player is in the center of the image so sprite_width / 2 will start the collision at the edge.
     
  3. Dmitri Pisarenko

    Dmitri Pisarenko Member

    Joined:
    Jun 9, 2018
    Posts:
    13
    Thanks!
     
    Cowlord likes this.

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