How do I Basic Door to Another Layout

Get help using Construct 2

Post » Thu May 04, 2017 11:54 am

Hi guys,

How do I get my player to go from one layout to another (Door Mechanic). Should be simple enough, but code doesn't seem to function.

Player_Object: on collision with Door1 = Player set position to Entrance1

Also tried adding additional action = System go to Layout X. Which works but does not take Player to Entrance1.

So what needs to change?

Faraz
[ Creative Director | Producer ]

www.farazjafari.com
B
16
S
7
G
1
Posts: 19
Reputation: 1,790

Post » Thu May 04, 2017 11:56 am

Wouldn't it be more logical to move to the new Layout before position your character?
If your vision so exceeds your ability, then look to something closer.
Moderator
B
131
S
29
G
81
Posts: 5,328
Reputation: 56,630

Post » Thu May 04, 2017 12:12 pm

zenox98 wrote:Wouldn't it be more logical to move to the new Layout before position your character?


Gives me the exact same result.
[ Creative Director | Producer ]

www.farazjafari.com
B
16
S
7
G
1
Posts: 19
Reputation: 1,790


Post » Fri May 05, 2017 12:42 am

@ TheZinc - you need the code to set the player to the position in the new layout you've just loaded, not the previous one. What I do is have a global variable that keeps track of what side of the screen the player exited from on the layout previous, so North, South, East and West - then when it goes to the next layout it checks what the previous door was and set the player accordingly - eg if the player exited from an East door last screen it will set them to a West entry on the next, and if they exited from a North door it will set them to a South entry.
B
64
S
25
G
4
Posts: 204
Reputation: 6,993

Post » Sat May 06, 2017 9:08 am

@signaljacker Thanks dude it makes sense. Though probably a little too complicated for the to execute right now. What I decided to do is just work on a single layout for simplicity and see how that goes. The code now works correctly. However, I've run into another hurdle.

How do I go about reversing the door objects function? Where I can use the same entrance to return to the door (In & Out Mechanic).
I've attempted to make a set 2 of the door and entrance (with same code) which doesn't seem to work and confuses the engine.
[ Creative Director | Producer ]

www.farazjafari.com
B
16
S
7
G
1
Posts: 19
Reputation: 1,790

Post » Sat May 06, 2017 10:57 pm

Can you post a .capx and I'll have a look. It's hard to tell as there are many different ways it could be done so need to see your door mechanic first. One might be to have a variable on the door itself which is toggled when the player accesses it and depending on its state takes you to the correct place.
B
64
S
25
G
4
Posts: 204
Reputation: 6,993

Post » Mon May 08, 2017 2:22 am

Hey @signaljacker

Here is the link to the .capx
https://1drv.ms/u/s!AmL7frOTdrlpmTUDL1j1WXUP1SQn

Thanks for taking the time!

And apologies for the delay.
[ Creative Director | Producer ]

www.farazjafari.com
B
16
S
7
G
1
Posts: 19
Reputation: 1,790

Post » Mon May 08, 2017 7:29 am

It is very easy. Many people do this mistake. On collision with with door 1 ---> go to door 2

then they do on collision with door 2 --> go to door 1

See the problem?

This creates a loop. When you collide with door 1 you go to door 2 and you collide with that one as soon as your player is there and you'll end up teleporting back and forth between the doors endlessly. So you have to think how to prevent it.

Here is a fast solution for it: https://1drv.ms/u/s!AowQiuoNUifdid0yIAU1IHBag5HedA

There are many ways of doing it and if I do doors I create a family and create events once for the whole family and not for every single door.

But the idea is:

1. Have a bool on the player "canPassDoor"

2. on collision with door and is canPassDoor = true ---> set canPassDoor to false and then move the player to the other door

3. And after the player has teleported to the new door then set canPassDoor back to true again


This prevents the player from teleporting back and forth as the variable is false when the collision with the next door is triggered.
B
52
S
22
G
12
Posts: 725
Reputation: 11,716

Post » Tue May 09, 2017 12:33 pm

@anonnymitet Hey thanks for taking the time to actually make those changes. I can clearly see the changes and their effects.

I will go about making this family events things as this will be more efficient long-term.

Also terming this a door was a poor choice of wording as it functions more like a portal than a door.
[ Creative Director | Producer ]

www.farazjafari.com
B
16
S
7
G
1
Posts: 19
Reputation: 1,790

Next

Return to How do I....?

Who is online

Users browsing this forum: jaytrott86 and 10 guests