Set Object to Global at RUNTIME?

0 favourites
  • 7 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Well... i'm working on a little something and my player (set to global) can pick up boxes and carry them around...

    i want him to be able to carry the boxes over to the next layout...

    this works if i set the property of a box to global in the editor but i need this to be dynamic... if i set the global property of my boxes family to true it ofcourse fucks up everything because each box is on each layout basically :D

    i saw that the global property is not exposed in the events but i don't want to do it via events :/

    wouldn't be much more work (check variable, is carrying box? yes -> spawn box and set to player xy) but maybe someone else has a better idea :)

  • fucks up

    I just needed to quote this one :P

    ...

    Now , enough time wasted , let's carry on

    That's why I dislike families , unstable for the moment

    Oh well , If all the boxes have the same events and only the art differs , you can put all the frames in 1 object an manually set the frame number on the start of the layout ...

    That way , all the boxes are one object

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ouldn't be much more work (check variable, is carrying box? yes -> spawn box and set to player xy) but maybe someone else has a better idea :)

    You could also leave the boxes as global and destroy all the boxes not being carried at the end of the layout. This would work since all global means is the object won't be destroyed at the end of the layout.

  • Store the value in web storage then load it on the load layout?

  • R0J0hound that would work... but i forgot to say that you can reenter a layout after you left it... so all boxes there would be destroyed if you return xD

  • Why would all global boxes be destroyed if you reenter the layout? Are you destroying them on start of layout?

  • no, i've tried R0J0hound's approach by deleting all "uncarried" crates on exit of the layout and since they are global they won't reappear that way :)

    anyway... gameplay wise i found out that it's actually good that my player can't carry boxes to the next layout... heh :D

    but im still interested in setting objects to global at runtime... could be usefull in the future

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