Multiple portals with 1 or max 2 objects

Hello, im trying to make somewhat dynamic portals to transfer the player between two objects. I set the variables of the instances manually in the scene when building the level. At first i had one pair of portal objects per portal, which worked ofc, but noticed quite fast that there will be too many objects and too much manual labour for each portal. And since i move things around a lot in the scene, coordinates wont work.

This is my setup now, which does not work. In the scene i have 2 pairs of portal objects right now to test:
Portal A with numbers 0 as ID and 1 as destination ID teleports the player to itself.
Portal B with numbers 1 as ID and 0 as destination ID works.
The portal A and B with ID’s 2 and 3 do nothing.

My big weakness with Gdevelop is instance picking. So im thinking its that. I have not found a way to pick an instance with a certain variable, which would save me in many, many situations. So learning this would not just be of great help to me in this example.

Im grateful for any help with this. Or a completely different/smarter idea for making multiple portals.

I do not get your system
What does it do?

Like i see there portal A and portal B
Yet i don’t understand the problem
I believe you have different destinations which are set to some object
But i don’t get how that works

I am pretty sure solution will be easy
But i do not get why you doing it the way you do it

Well it doesnt work. :joy:.

Its so i can change only the variables of the portal instances in the scene and the rest is automated.
Each instance get an ID, which is where it is. And a destination ID, to which instance the player will be teleported. If they exchange those two ID’s the player can go back and forth between those two portals. And for another pair of portals we set different ID’s so they know where to send the player.

The issue you have is that if the w key is released and player is in contact with portalA1, then they are repositioned to porttalB1.

And in the event straight after that, the w key released is still true, the player is now in collision with PortalB1 and so the player is teleported back to PortalA1.

Your best solution is to change your events around so that you check for w key released, add a local boolean called “Processed” and set to false. The add 2 subevents:

  • The first checks for collision between Player and PortalA1, and changes the player’s position as you already do. Add another action to change “Processed” to true.
  • in the second subevent, check that the local variable “Processed” is false and keep the condition checking is Player is colliding with PortalB1. Keep the current actions for that collision.

BTW, don't use the repeat for each object and then check for collision. When you check for collision, GDevelop already filters the objects it uses to those that meet the conditions.

Something like this? This made one portal work, IDs 1 and 2. But 3 and 4 are dead still.

Nope, that’s nothing like what I suggested. A subevent is an event that comes off another event.

This is what I wrote you should do:

If thats javascript then you have me running for my life. The rest i tried, unsuccessfully.
Its so frustrating getting stuck with this little thing that feels like it should be very straightforward.
Guess i need to find a new way. Ideas are welcome.

That’s not javascript. It’s all plain GDevelop local variables, event conditions and actions.

Can you screen snip what you’ve implemented?

Im still on Gdevelop 4.3, maybe thats why i didnt find any local variable additions. I still need to learn more about what the update does and how much work it will be to continuing what im doing before i update.

I wrote what you wrote, without the local variables. Now its another step towards working. As both B-portals work. :smiley: But not the A’s.

Screen shot the events, and we’ll have a go at spotting the problem.

Thank you for your patience.

Instead of the local variable, create a scene boolean variable, set it to false in the event where you check the w key release and use it like the local variable in my event screen snip

Your’e a gem! :heart_eyes: It works now. I dont know how yet, :joy: but im gonna find out. I dont use things i dont understand. So you’re teaching me a lot. Thank you. :heart:

1 Like