How do I interact with other sprites

0 favourites
  • 3 posts
From the Asset Store
A set of 10 pixel art animated magic effects with icons. 2 Fire, 2 Earth, 2 Wind, 2 Water, Portal, Explosion.
  • Alright, so what I'm trying to do is implement a system where if the player is near an object (say an NPC or a signpost), you can press a button and either talk to the NPC or inspect the object in question.

    A lot of dialogue tutorials I see have it so when you collide with an object then it starts the conversation but I don't want it to happen every time the player touches an NPC

    So, in summary, what I'm asking for help with is:

    -Allowing the player to interact with an object

    -Not using only collision as a means of making an event trigger.

    Ideally it would be while the player is within a certain range of the object, that is, practically pressing against the object.

  • Still the objTrigger is a great way to do that. You can destroy your helper object so it doesn't appear again - or give the invisible object an instance variable.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • if abs(player.X-NPC.X) < range AND abs(player.Y-NPC.Y) < range { your action }

    If the range is the same for X and Y you could use: if distance(player.X, player.Y, NPC.X, NPC.Y) < range { your action }

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