Player special Teleporter how to?

Ok, i want the following:

Everytime i create the Sprite: “Teleporter”,
the ObjectValue of "Teleporter “ID” is set to +1
(it starts with zero).

Now i check:
If my Player is standing on top of (for example) Teleporter(ID1) and presses a key,
he will change the Position where Teleporter(ID1)+1

So, how to do the LAST STEP?
I tried this, but it does not work.
where to put the “+1”?

Hm. Alright. Let me try to make an event list. You can find a “for each” event by clicking on the plus at the top right, I believe. Four dots represent a sub-event.

Player is standing on top of teleporter and Player pressed key (E) : Store teleporter ID in scene variable “teleID”
…For each teleporter, if teleporter ID == sceneVar(“teleID”)+1: set player position to teleport.x, teleport.y

I think this should work.


1 Like

Your portals are one way by the sounds of things. Is this your intention?

Anyway to get what you’re after:

In the first event in your screen shot, add an action to assign the target teleporter id to a scene variable (say _targetTeleportId)

change the event with the red box to have the conditions and actions:

Object variable ID of Teleporter = Variable(_targetTeleportId)
set PlayerHitBox postion = Teleporter.PointX(“PlayerCheck”) (X axis), Teleporter.PointY(“PlayerCheck”) (y axis)

(Change the pont name PlayerCheck to what ever point you have defined).

No need for a foreach loop, the condition will select the portal with the id.


Doh, you’re right. For each isn’t needed as there are multiple conditions for the teleporter to fit.
A for each would be needed if “teleID==currentTeleID+1” were in a subevent.

1 Like

tried it out exactly this way yesterday.

Now i have two Objects:
Teleporter with an ID (works)
Target Object (hidden) with an ID (works).

I do it this way:
when Player is in collision with Teleporter and presses down,
change position to the Target

I don`t know why, but when i place 3 Teleporter and 3 Targets,
when i do it on Teleporter 1, it works
when i do it on Teleporter 2, it changes position to Target 1 (should be 2)
when i do it on Teleporter 3, it changes position to Target 1 (should be 3)

So it seems not to work. Perhaps you see the mistake i made:

I think the problem is that the third event in your screen shot will apply to the first teleporter it finds. It’s not being applied to the Teleporter from the first event.

Also, will the Telport variable of Gunnar only be set in the first event? If so, make the third event a subevent of the first one, and get rid of current second event - so it looks like:

1 Like

Hmm, doesnt change anything.

I need the Teleport variable of Gunnar to set some animations and other settings. I just deleted them until the destination of the teleport works.

So the question is the same: how to tell the “change position of gunnar” which Target i mean?
When he stands on Teleporter 1, Target should be Target 1,
When he stands on Teleporter 2, Target should be Target 2.

I need something like:
when Gunnar is in collison with ID of Teleporter 3 → change position of gunnar to Target.objectvariable(ID = the same where Gunnar stands on Teleporter).

Theres no such function, so i need a workaround.

Did you read my first reply and implement it? Because it’s not in your screen shot.

Hmm, i think i don`t understand. My english sometimes is not good enough.

which action do you mean with “say”, and what is targetTeleportId?
I have a object “Teleporter” (starting point) with the id: “ID” as a object variable
I have a Target “Portal” (target point) with the id: “Ziel” as an object variable

So I only have a Teleporter.ID and a Portal.Ziel, not a TargetTeleportId…

the global variables “target” and “beamer” are only used to give every object an own id (“ID” for Teleporter and “Ziel” for the Portal).

Sorry, perhaps i don´t understand.

I don´t want the Player to beam to another Teleporter, i want it to beam to a fitting Portal.

My intentions is the following:
When i create for example 3 Teleporters, the first should have ID1, the second ID2 and so on.
When i create 3 Teleporters, i also create 3 Portals, which IDs (i named them “Ziel”) are also 1 for the first, 2 for the second and so on.

so if the player stands on Teleporter1 and presses down, he should beam to Portal1, if he stand on 2 and presses down, he should beam to Portal2 and so on.

Like the green Tubes in Mario.

Hey, in future, could you quickly switch to English before screenshotting events? It’ll help us wrap our brains around the code faster.
I have misunderstood. I thought you said: After pressing down key, teleport to the next teleporter. Sorry about any confusion that may have caused. :grimacing:

Hmm. One part to check might be the variables assigned to the teleporters and portals. Are you sure you don’t have 3 portals with the same variable?

Player is standing on top of teleporter and Player pressed key (down) : Store teleporter ID in scene variable “teleID”
…(For each portal may be needed) if portal ID == sceneVar(“teleID”): set player position to portal.x, portal.y

If this goes nowhere, it might be good to just send us the project file, and we’ll send back a solution.

Auf Wiedersehen.

1 Like

Can you screen shot what you’ve done?

1 Like

I will! Maybe tomorrow, but i promise i will. Hope it will work.

Is this the kind of thing you’re after? Yellow are the teleporters, green are the portals (arrows in the top left indicate what keys were pressed):


If so, the code for it is:


Wow! Looks very interesting, but if i am right (as a newbie), isnt the target Portal random?

So the more i look on the code, the more sense it makes. could it be that easy? And when i say easy, i mean short… impressive. have to sleep now, tomorrow familiy day, and then i can be back on my loved project game to test it out!

For now, thank you very much!

Ah, I forgot to mention that each portal and teleporter has an Id:


And similarly for the other teleporters and portals, but with different Ids.

Yes, And that’s one of the beauties of GDevelop - you can get a fair amount done with minimal effort.

Could not sleep well that night. Days you work on the project and it never lets you go. So about 2 hours before my wake up time i tried it out and:

It works! The Problem is solved! Thank you so much!

This is what i made of it:

And also under this:

And this is the way it looks now, when Gunnar is beaming (I will hide the Portals, and next days i will change the Portal Animations from barrels to a well or something. )