How do I interact with other sprites

Get help using Construct 2

Post » Tue Apr 12, 2016 8:16 am

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.
Posts: 1
Reputation: 177

Post » Tue Apr 12, 2016 9:02 am

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.

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
Posts: 340
Reputation: 4,707

Post » Tue Apr 12, 2016 9:05 am

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 }
Image Image
Posts: 894
Reputation: 82,761

Return to How do I....?

Who is online

Users browsing this forum: R0J0hound, socialpilgrim and 6 guests