Pairing instances with matching variables, picking the other instance?

  • I have several doors, all the same object, with different instances paired by a variable. For instance, if you go through a door with DoorID = 0, the player should appear at the other door instance with DoorID = 0. I can't figure out how to pick the other instance that has the matching variable. Then I can set a DoorUID variable to each other's UID, and store the other doors X/Y position in another couple of variables. I can't get it to stop picking itself, every time it just set the DoorUID variable to it's own UID. How should I approach this?

  • I liked how you used instance then said for instance, that confused me for a sec. Anyway...

    I would approach this by matching them up as follows. Doors have IDs, but don't pair them in that way.

    Door A, the ID is 0.

    Door B, the ID is 1.

    Lets say they work as A goes to B, B goes to A like portals.

    You have a variable on the door additional to ID, something like GoTo.

    Door A, ID=0, GoTo=1.

    Door B, ID=1, GoTo=0.

    When you overlap a door, you teleport to a door where door being overlapped.GoTo = door.ID.

  • You can save the ID and UID of the first door in local variables, then pick all doors, and then pick a door with same ID and a different UID. Something like this:

    Player on collision with Door
     variable doorID=0
     variable sourceDoorUID=0
     
     -> Set doorID to Door.ID
     -> Set sourceDoorUID to Door.UID
    
     System Pick all Door
    
     Door compare variable ID=doorID
     Door pick by unique ID NOT equal to sourceDoorUID
     ----> Player set position to Door
    
    
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the suggestions! I'm using rex's UID2Properties so I can just pick a destination door's UID, place it in a variable for the leaving door, and have the plugin take care of the new position. Thanks for the help!

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