How can I assign objects X and Y value to variables at the beginning of layout?

0 favourites
  • 3 posts
From the Asset Store
Color Variable
$4.50 USD
10% off
Easily store, modify, read and manipulate colors with Color Variables!
  • Hi all,

    I have a door which has position of X and Y and need these values to be stored as variables at the beginning of the layout so I can return the object to its initial position when moved - in other words, I need to remember the position so I can return it there when I need. I did:

    local variable objectXvalue=0

    local variable objectYvalue=0

    then I created event:

    system -> set value -> set objectXvalue to object.X

    same with Y value. But nothing happens. When I return it to initial position it returns to x=0, y=0 (as set at the beginning of the layout). Seems like it is not assigning the value of object.X and object.Y to variables.

    Any idea how to solve it?

    Thanks

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Local variables are reset at the end of each tick, unless you set them as static.

    In your case it's better to use instance variables on the door sprite. Instance variables are not reset and each instance (each door) will have its own values.

  • Oh, I did not know this,that is very useful information, thanks.

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