Sliding Doors and Lighting Lights

Get help using Construct 2

Post » Mon Apr 01, 2013 3:24 pm

Regarding the lights part first:

I have a system set up where if you approach a wall, the texture will change to show that it has lit up. It works, but I want it to work for every member of a family, which means that any character will light up a wall when they walk up to it (NPCs). It's not working out that way though. It will only light up when the player approaches the walls, and I can not figure out why.

Regarding the sliding Door:

I'd like to have it so that when these characters approach doors, they will slide open. They are 64 pixels wide, and I'd like them to slide open when characters approach. The thing is I can't think of a simple way to do it. I want it to reverse back on itself around 60 pixels when the characters are a certain distance away. Then, when nobody is close enough, the doors will move back into their original position. I'd like to do this using the sine behaviour, but I can't figure out how. My only options are horizontal and vertical, rather than forward and backward.

Hope I'm making sense, and I hope somebody can help with either or both of these issues :)

Link to game
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 929
Reputation: 9,356

Post » Mon Apr 01, 2013 3:43 pm

You could add an other for each into your first for each. Something like:

For each "Walls"
- set frame to 0
- for each Bios > do the distance check and set frame to 1 where true


For the doors you should probably not use the sine behaviour but just move it out of the way when the player (of an enemie) is overlapping it. You could extend the bounding box to have it trigger when someone is close and then move it back to it's origional position when they aren't overlapping.

edit: here's a capx with the fixxed lighting: https://www.dropbox.com/s/g7wfcp8vr61c2g7/SpaceStation.capx
kingpenguin2013-04-01 15:45:04
B
4
Posts: 5
Reputation: 710

Post » Mon Apr 01, 2013 5:30 pm

Regarding the wall lighting, the real issue is that you're not picking a specific Bios instance when you're testing to see if a Bios is in range of a wall . C2 doesn't know which instance you want to test, so it just picks the first one. Kingpenguin's solution works, but you really only need to check to see if the nearest Bios instance is in range, so I'd suggest picking the nearest Bios to each wall before checking its range.

Regarding the doors, I agree with kingpenguin that the sine behavior is probably not appropriate. There are a number of ways to have the doors open when an instance is in range. The first way that came to mind is to calculate the open and close coordinates of each door upon the start of layout, save them to instance variables as well as each door's starting coordinates. If an instance is in range, move the door to it's open coordinates. If no instance is in range, move the door to its starting coordinates.

Here's a capx fixing the lighting and moving doors as I suggested:

Capx

I added "every 0.1 second" to make processing a little less intensive.zatyka2013-04-01 17:31:15
B
44
S
13
G
7
Posts: 338
Reputation: 10,379

Post » Mon Apr 01, 2013 7:09 pm

Very clever! Thank you very much!
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 929
Reputation: 9,356


Return to How do I....?

Who is online

Users browsing this forum: Muini and 17 guests