How do I make player interact when near an object?

Get help using Construct 2

Post » Thu Dec 25, 2014 2:46 pm

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?
B
5
S
1
Posts: 3
Reputation: 542

Post » Thu Dec 25, 2014 3:00 pm

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:
Capture.PNG


Add whatever makes sense to opening the door. You might use a private boolean variable like "Open" to toggle it opening and closing, etc.
You do not have the required permissions to view the files attached to this post.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Fri Dec 26, 2014 12:43 am

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
B
7
S
1
Posts: 28
Reputation: 481

Post » Fri Dec 26, 2014 2:39 am

or use conditions like "pick nearest/furthest" or "pick by comparison" or "pick by unique ID"
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Fri Dec 26, 2014 3:53 am

sgn15 wrote:or use conditions like "pick nearest/furthest" or "pick by comparison" or "pick by unique ID"



Or line of sight behavior....
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Fri Dec 26, 2014 6:51 pm

Or is overlapping at offset... :)
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
20
S
6
G
3
Posts: 637
Reputation: 3,776


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 46 guests