Close an automatic door only when player is far away enough

0 favourites
  • 2 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • The topic says it all: I can't figure out how to achieve that.

    I have multiple Doors in my layout that do open automatically using a coordinate-tween upon collision with the player. That does work great.

    Then i use a timer to close that particular door automatically after a couple of seconds.

    Now my BIG problem: I don't want it to "crush" the player, should it be within the door's closing range

    I know there's the distance expression, and that should do the trick, however, how can i tie that to the door instance that just triggered the last (door open and close) event?

    Unfortunately i cannot do System -> Compare two values -> first value -> distance(Self.X, Self.Y, Player.X, Player.Y). That would be so easy. Too easy, maybe.

    Am i missing something? Do i really need to store the last door's X and Y globally for that to work? That would surely mess up things with multiple door events within a short timeframe i am afraid.

    Can anybody enlighten me? Thanks so much :-)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • SOLVED! I did fix my problem via using another condition upon the firing of the door close timer.

    I used a System -> Pick by comparison -> Object: Player, Expression: distance(SlidingDoor.X,SlidingDoor.Y,Player.X,Player.Y), Comparison: > Greater then, Value: 50.

    So, whenever the door close timer fires, it will also check if the player is not closer than 50 pixels to that door before actually closing it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)