How do I manage object instances?

0 favourites
  • 5 posts
From the Asset Store
I-Spy (Hidden objects)
$34.30 USD
30% off
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • Coming from engines such as Godot and unity, When I create an instance of an object, I'm expecting it to inherit properties of that object. But I'm noticing this is not the case in Construct 3 and I'd like to understand it better.

    For example, if I create a timeline animation for an object, it's only valid for one specific object. I get 'around' this by creating a scratch scene, animate the object there, and then when I want to animate an actual instance I set the animation instance target first. This works, but seems like a tacky workaround.

    Secondly, I wanted to create an instance level property for the contents of a chest, but it seems that if I create an instance variable, the value is shared by all object instances (not just the variable itself).

    Thirdly, if I create a TileMap, the first instances values seem to be retained for all future versions on other scenes. I can change the contents and the data stays independent, but it's just... strange.

    What am I missing here?

  • Hey, I'm not quite sure I understand your first issue. However, instance variables are independent, but can be set individually or for all depending on how you set up your events. If you haven't already have a read of these.

    construct.net/en/make-games/manuals/construct-3/project-primitives/objects/instances

    construct.net/en/make-games/manuals/construct-3/project-primitives/objects/instance-variables

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's an example of what I'm talking about...

    Notice it's referencing EmptyBox - 15. I cannot define a timeline unless it is specifically referencing an instance of an object type. If I were to delete this object typist he timeline would go blank and have no value (this is how I ran into the issue.. I deleted all instances of the empty box and my timeline change to showing nothing). I fixed it by having a dummy layout with the animation defined, but this seems weird and tacky.

    For the instance variable thing, I tried it again and this time it worked, so I'm guessing it was a weird IDE bug.

  • Oh and this is what I mean by associating an instance before playing an animation.

  • Yes that's normal behaviour the timeline needs an instance to exist in order for it to effect that instance, then you add other instances to the track as required.

    Back to the inherit thing. If you are generating instances at runtime and do not have any in the layout editor is common practice to place an instance of an object outside of the layout (this can be destroyed at start of layout if necessary). Any instances created will inherit the instance variables that this original instance had when the layout started regardless of if it is destroyed or not.

    Once you get used to it is is really handy. Also if you want to change instance variables of a newly created instance, simply make those changes in the same event after the creation action.

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