How do I make player interact when near an object?

0 favourites
  • 6 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • It is a week now that I'm trying to figure out how to make the player interact with an object when the "player" sprite is near the interested object?.

    For example, in a top-view game, how do I make the player able to open a door, just when the "player" sprite is near the interested "door" sprite, by clicking the "E" button?

  • You could probably check the distances between the door and the player - just do it only when E is pressed so there's no unneeded resource use.

    So basically:

    [attachment=0:1p5k0vbf][/attachment:1p5k0vbf]

    Add whatever makes sense to opening the door. You might use a private boolean variable like "Open" to toggle it opening and closing, etc.

  • another way is to make a "ghost zone" which is an invisible (set to invisible) square around the objet, set in other layer that is bigger than the objet (ie the dor, or an NPC) so if the player and the "ghost zone" are overlaping and the player press "e" get the action

  • or use conditions like "pick nearest/furthest" or "pick by comparison" or "pick by unique ID"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • or use conditions like "pick nearest/furthest" or "pick by comparison" or "pick by unique ID"

    Or line of sight behavior....

  • Or is overlapping at offset...

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