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.
B
3
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
B
17
S
8
G
5
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
B
25
S
14
G
137
Posts: 876
Reputation: 71,505


Return to How do I....?

Who is online

Users browsing this forum: ratboy3 and 45 guests