Own Object name for every object

Hi everyone, im trying to make a teleportsystem.
My idea is to make a object called “portal”. That have a object variable called “ID”
I want to teleport the player from the Teleport Nr1 to Teleport Nr2
I tried to program something like:
Change x-pos of Player set to portal.ID2
Change y-pos of Player set to portal.ID2

I dont know how to name a own object with his own ID
does anyone know a solution?
i think i have to write something like
Change x-pos of Player set to portal.ID(2)
Change x-pos of Player set to portal.(ID2)
or whatever
Thanks for help :slight_smile:

Assuming you have a scene variable targetPortalId, which you’ll need to store in the portal you just stepped into

Create an event with the condition portal.Variable(ID) = Variable(targetPortalId)
And then in the actions, set the player co-ords to portal.X() and Portal.Y() (or wherever on the portal you decide to place the character).

You’ll also need to keep track of whether the portal the character is on is one they’ve moved onto, or been teleported to.

Thanks for help. Do you know whats the name of a portal with the object variable number 1?
portal.ID1 or portal.(ID)1 or how to write this?

You cannot directly reference a specific instance of an object in the scene. This takes a bit of getting used to.

You determine which one(s) you want by setting the condition of the event, and any reference to that object in that event’s actions (or subevents) will affect the objects that matched the conditions. This takes a bit to get your head around it, but once you understand how it works, you’ll be able to use events effectively.

For example, say you have a scene with two portals, one with ID = 1, the other ID = 2. In the event snippet below, the condition is treated as an IF statement, and it’s saying to apply the actions to the portals that have an ID = 1. i.e. If the variable ID of portal is 1, then hide it. If you have multiple portals with ID = 1, then they would get hidden too. But any portals with ID not equal to 1 are ignored.

So, only the portals with ID = 1 would be hidden because the condition narrows down the selection:

However, with this following event all portals get their colour changed because there is no condition to select a subset of portals:

1 Like

Wow thank you that will help me :slight_smile:

Thank you. My system works now. Would be great if i could make an example file for teleportation in Gdevelop, have a nice evening