How do I Basic Door to Another Layout

0 favourites
  • 12 posts
From the Asset Store
Transition Layout C3
$22.50 USD
10% off
Plugin Transition Layout C3. Layout opening and closing animation for C3. Quickly set up transitions between lay
  • 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?


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

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

    Gives me the exact same result.

  • 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.

  • 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.

  • 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.

  • Hey signaljacker

    Here is the link to the .capx!AmL7frOTdrlpmTUDL1j1WXUP1SQn

    Thanks for taking the time!

    And apologies for the delay.

  • 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:!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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Anonnymitet I've gone ahead and made the event into events. Though I've ran into another hurdle that I can't get my head around.

    I've made a family under 'Doors'. Which includes the Boolean that you used "PassDoor" with the following actions:

    Player set PassDoor to False

    System wait for 0.5

    Player set PassDoor to True

    But how do I go about the Player on collision with object DoorA > Player set position to DoorB and vice versa. How is this done using families? Or alternatively how is it done when the other three actions are executed under a single family?

  • Bump.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)