Realtime Instance Grouping

0 favourites
  • 6 posts
From the Asset Store
Basic Plugins for Firebase Authentication, Realtime-Database, Firestore, Cloud Storage
  • So I've run into this problem with various projects, and before I make an complicated an bulky solution I'd like to know if anyone has found a simpler way. A lot of object have events that apply to all instances of that object. For example, if I have a physics ragdoll, copy that ragdoll, the physics will be shared between both instances of the ragdoll. I need to figure out a way that allows me to use the same object types and to treat each group of specified objects as it's own instance. If I'm not making sense let me know, does anyone have an idea to do this?

  • You have to pick which object you're referencing to.

    You can do this by creating an event "System -> Pick", or "Object -> Pick", there are a lot of options on there (such as pick nearest to something, pick nth instance, pick by UID, etc).

  • You have to pick which object you're referencing to.

    You can do this by creating an event "System -> Pick", or "Object -> Pick", there are a lot of options on there (such as pick nearest to something, pick nth instance, pick by UID, etc).

    That sounds good on paper but I can't find a practical way to implement it. For example, I have three object types, when you shoot them, a particle is created that moves with that object. How would I pair the particles, notice that if you shoot the objects too fast the particle will apply to the wrong instance.

    Demo

    Project File

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Picking by Unique ID is the way I would do it in this case.

    I Added an instance variable to Particles called Victim, and when the Particles object is created I store the Sprite.UID in the Victim variable so we now know the Sprite that the Particle object is associated with.

    Then I added a loop in the Every Tick section, for each Particles, we pick the Sprite with UID = Particles.Victim, then set the Particles position to that Sprite's position.

    I also randomly create new Sprite objects to shoot... :)

    Oh, I also added Fade to Sprite and Particles, so that they fade out of existence - because the bodies were really starting to pile up, and the Particle instances were still active even after the rate was reduced to nothing.

    you can get the file here: rieperts.com/games/forum/sniper.capx

  • My son has been making games with enemies, and wanted a health bar over each one. So, when he places each enemy on the layout, he puts a health bar near it. Then at the start of the layout he loops through each enemy, picks the nearest health bar, and pins it to the enemy. And puts the health bar UID in an instance variable in the enemy, so when the enemy takes damage he knows which health bar to reduce.

    That is another way to handle this type of problem...

  • AllanR

    Thanks for all the feedback and advice! I'll try implementing it in my project when I get a chance.

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