Making portals that automatically know which is the next one

So in my game when an enemy arrives at the portal on the edge of a floor they will be teleported to the next portal on the floor below. Now I was wondering if there was a way to make it so the portals know which the one is, a new portal each time. Like when the enemy is going down from floor 5 to floor 4 the game would know that and do it. But then from floor 4 to floor 3. How would I accomplish this? Thanks for any help : )

You’ll need to add 2 instance variables to the portal objects - one being a unique identifier (i.e. each portal has a unique id), and a second instance variable for the destination portal id. Use the destination portal id to find the destination portal.

How would one accomplish this?

In the objects list, right click the portal object (or choose the three vertical dots). Choose Object variables (2nd item). You can then add the two variables (names on left, values on right) as said above. In the events sheet, the collision event will have an action, and the action can read the property of the given portal that is in the collision: you can get the “destination address” from the Portal (or whatever it is called)'s Object Variable value, and use this to jump to the next scene/level/co-ordinates.

1 Like