Doors That Move the Player

Get help using Construct 2

Post » Sat Feb 09, 2013 2:03 am

Hi, guys. I'm new to construct and I'm having trouble getting my doors to work correctly.

The Problem:

I have four doors in a level. All use the same sprite. Door 1 should to door 2 and vice versa, and door 3 should lead to door four, and vice versa. Now, I could just make four separate doors and four separate events, but this strikes me as inefficient. Is there any way to tell each instance of a door apart and ensure they all lead to the correct door? HugeCorporation2013-02-09 02:12:36
B
5
Posts: 4
Reputation: 708

Post » Sat Feb 09, 2013 9:49 am

@HugeCorporation Inefficient but necessary, and simple. There is no way to set a position to a specific frame. (I think) There is no reason not to make four doors. ;) superwifibattler2013-02-09 09:50:44
B
11
S
2
G
4
Posts: 78
Reputation: 3,292

Post » Sat Feb 09, 2013 10:07 am

[QUOTE=HugeCorporation] Hi, guys. I'm new to construct and I'm having trouble getting my doors to work correctly.

The Problem:

I have four doors in a level. All use the same sprite. Door 1 should to door 2 and vice versa, and door 3 should lead to door four, and vice versa. Now, I could just make four separate doors and four separate events, but this strikes me as inefficient. Is there any way to tell each instance of a door apart and ensure they all lead to the correct door? [/QUOTE]

You'll need to pick the instance of the door via event. You need to have something to tell the doors apart, be it variable, distance from player or whatever condition fits your situation. Check the 'picking' section in the FAQ

Here is also an example with lots of picking functionality. Only the AI events are by me, everything else is not :)

So no, you don't need to make multiple events or objects.vee412013-02-09 10:07:44
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Sat Feb 09, 2013 10:09 am

Actually there is a way...And it's always a good idea to be as efficient as possible...just set each door an instance variable say "door number",to identify it...then create a global variable "choose door" that identifies it

>>on collision with door >set global choose door to (door number you want to go to)
>>variable door number=choose door >set position to "doorspritename"

hope that helpsPixel perfick2013-02-09 10:40:27
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Sat Feb 09, 2013 10:14 am

[QUOTE=Pixel perfick] Actually there is a way...And it's always a good idea to be as efficient as possible...just set each door an instance variable say "door number",to identify it...then create a global variable "choose door" that identifies it

>>on collision with door
>>variable door number=choose door >set position to "doorspritename"

hope that helps[/QUOTE]

Actually you could do that with just

player on collision with door
.. open door

On collision trigger automatically picks the colliding objects so there is no need to pick them again. :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Sat Feb 09, 2013 10:28 am

Sorry, edited post. You are looking for a warp type door it seems.spongehammer2013-02-09 10:33:33
B
44
S
15
G
9
Posts: 1,096
Reputation: 11,013

Post » Sat Feb 09, 2013 10:28 am

@vee41...yes but he wants a "warp door"...does he not?...the global is doing the picking...or is it too early in morning?...lol
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Sat Feb 09, 2013 10:32 am


@Pixel_perfick You are correct, it is too early and I have to read stuff more carefully. Thanks! :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Sat Feb 09, 2013 10:41 am

@vee41...ditto,I forgot to add the change global bit...edited...thanks..
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Sat Feb 09, 2013 1:15 pm




I only had to use Is overlapping with trigger once for collision detection .
"Player On collision with Door" was giving me strange results.
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests