How do I get coordinate of specific object?

0 favourites
  • 6 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • I have a "Home" object with two instances on the layout.

    I have two global variables for currentX and currentY

    I want to set currentX and currentY when my player object overlaps either one of the "Home" objects.

    How do I get the X, Y of the specific "Home" that is overlapping the player.

    Thanks

  • If you use the condition 'player is overlapping home' then it 'picks' the correct home object. Then with the actions on the right you can happily set the global variables to home.x and home.y.

  • Hello, thanks for your reply. I have already set that condition up, but I cannot get access to the global variables on action of “Home”, only instance variables.

    If I change the action to use system then I can access the global variables, but now I don’t have the specific “Home” object to get coordinates.

    Am I missing a behavior or separate step?

    Thanks for any help.

  • On the action you use system 'set value' and you should be able to use Home.x or Home.y

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That worked, Thank You.

    I was over complicating it. I used system action as you suggested, set value to home.x and home.y and "it" knew which home I needed. Thank You!

  • No problem! Just to clarify again it knows which instance of Home to use because of the conditions on the left. In Construct you can narrow down picked instances with conditions on the left. If you don't narrow it down then it picks the single instance with the lowest UID. You can also use 'for each' instances to run actions for every instance.

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