Teleporter (I'm Stumped)

0 favourites
  • 5 posts
  • Ok I'm Stumped.

    I want to have a "Portal" sprite object which I can duplicate.

    Then link the to portals together..

    So when the player hits a portal,, it teleports him to the associated portal.

    So I have two instance variables, State and Connection.

    State being is it a entrance or exit (really just for the animation)

    and Connection being a number that would link the two.. ie 0 and 0 link together.. 1 and 1 link together.

    Problem when I have the player detect collision with a portal.. I can't figure out how to "pick" the linked portal..

    Then I will just set the player position to the other portal..

    I thought about using two sprites .. an A. portal and B. portal.. but still have the same problem if I want more than one set of portals. I still need a way to "pick" the linked sprite.

    Thanks in advance for any help/suggestions you guys have.

  • Lazy man's way to do it: have 2 object types: portalA and portalB. Same instance variables as you had before. Have code for A to B and B to A.

  • Yeah this is how I was thinking..but what if I have 2 portalA's and 2 portalB's in the same level. I can't figure out the code to have it know which portalA connects to which portalB. I have the instance varaibles, but I dont know how to compare them in code.

    So I want to say.. If player collides with portalA, and portalA connection = 0 pick portalB with connection = 0 and set the player position to portalB.

    I can't figure that out in construct code.

  • When you collide with a portal, set a global variable called HitConnection as the portals Connection variable. Then, have a subevent For Each Portal and Portal.Connection == HitConnection -> Set HitConnection to -1 (To avoid referencing another portal afterwards) then set position to Portal.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think I got it figured out.

    using EncryptedCows method.

    Thanks a million

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