Check if a player is near an object and clicking

0 favourites
  • 4 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • Hello,

    I'm starting to build a top down platformer like the original zelda. How can I check if a player is clicking on a sprite and is also near them (on collison with?)

    That way they will only be able to do damage to the sprite if they are next to them.

    Thank you!

    Sparty

  • That is very easy. Lets suppose the name of player sprite is Zelda and name of enemy sprite is Zombie.

    FOR EVENT

    MOUSE on click on the zombie

    SYSTEM distance (zelda.X, zelda.Y,zombie.X, zombie.Y)

    Is less or equal than 100

    FOR ACTION

    Zombie destroy (or substract from zombie "heath")

    Its always better to put imagem but on this forum it so complicated.

    And istead of 100, you can put any number.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That makes perfect sense except I can't find this distance comparison you mention.

    Could this have to due with me using a free license?

  • The condition you're looking for is 'System: Compare two values'. Put "distance (zelda.X, zelda.Y,zombie.X, zombie.Y)" as the first value and 100 as the second.

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