Multiple Instances, Independent Behavior [Solved]

Get help using Construct 2

Post » Mon Jun 19, 2017 9:28 pm

My question is, how is it that I can have multiple instances of a sprite with AI that will behave independently from each other?

I have Drones in my game for mining asteroids. They have an instance variable for Cargo, and when it is below 1,000 they target asteroids to mine. Once Cargo exceeds 1,000 they return to the nearest Space Station to unload.

The problem I am running into is that as soon as one Drone wants to return, suddenly all Drones want to return. This problem is the result of me using Turret behavior for Drones to target either asteroids or stations, when one gets reprogrammed, they all get reprogrammed.

I could conceivably recreate turret behavior from scratch in a way that avoids this issue, but I would continue to run into similar issues in other areas of AI.

I could make many, many clones of the "Drone" sprite which all have their own unique events to program their AI, but this would be incredibly tedious especially since I plan on having a wide variety of Drones for performing different tasks.

Reading that I have done on this topic suggests that independent behavior among multiple instances could be accomplished with lists or arrays, but no articles or videos offered thorough explanations of how that actually works.
Last edited by Ajbael on Fri Jun 23, 2017 9:46 am, edited 1 time in total.
B
11
S
4
G
4
Posts: 28
Reputation: 2,831

Post » Mon Jun 19, 2017 10:10 pm

Hi, are you adding a 2nd condition during re-targeting where you require that the drone has >1000 cargo? Normally if you add this requirement then any ACTION that you specify will only happen to the specific drone who has met this requirement in that specific moment.

Worst case give the drones another instance variable called I_AM_FULL = 0
and then require drones to have I_AM_FULL = 1 during re-targeting

You can make the I_AM_FULL = 0 become I_AM_FULL = 1 using a TRIGGER ONCE action when the drone has 1000+ cargo

And remember to again set I_AM_FULL = 0 after re-targeting
Thank you to Construct 2 for giving me the ability to create games without programming knowledge.
My games & gaming portal = DolyGames
If anyone wants to cooperate to help each other Win-Win please email me - I am always happy to discover new opportunities.
Cheers,
COSMOS
B
21
S
11
G
1
Posts: 94
Reputation: 2,468

Post » Mon Jun 19, 2017 10:37 pm

No it's only one condition, here I'll show you.
http://i88.photobucket.com/albums/k166/ ... c4vu0y.png

But I'll definitely try your idea, using a second instance variable alongside Trigger Once and get back to you with how it plays out.
B
11
S
4
G
4
Posts: 28
Reputation: 2,831

Post » Tue Jun 20, 2017 12:05 am

DolyGamesCosmos wrote:Hi, are you adding a 2nd condition during re-targeting where you require that the drone has >1000 cargo? Normally if you add this requirement then any ACTION that you specify will only happen to the specific drone who has met this requirement in that specific moment.

Worst case give the drones another instance variable called I_AM_FULL = 0
and then require drones to have I_AM_FULL = 1 during re-targeting

You can make the I_AM_FULL = 0 become I_AM_FULL = 1 using a TRIGGER ONCE action when the drone has 1000+ cargo

And remember to again set I_AM_FULL = 0 after re-targeting


I tried implementing your idea but it isn't changing their behavior. I thought maybe I was misunderstanding how you meant it to be implemented so I tried quite a lot of experimentation but haven't made any progress.
Could you show me an example how this would work?
B
11
S
4
G
4
Posts: 28
Reputation: 2,831

Post » Tue Jun 20, 2017 12:23 am

This is a picking issue. Try adding a "For Each Drone", then checking the cargo as subevents. It should clear up the problem.
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
52
S
17
G
26
Posts: 436
Reputation: 18,092

Post » Tue Jun 20, 2017 12:37 am

cjbruce wrote:This is a picking issue. Try adding a "For Each Drone", then checking the cargo as subevents. It should clear up the problem.


I think I understand the problem and I think that this should work, but it isn't changing their behavior either. Again, I tried experimenting and implementing it in different ways but nothing worked.
B
11
S
4
G
4
Posts: 28
Reputation: 2,831

Post » Tue Jun 20, 2017 12:41 am

I'm beginning to think the issue is with the Turret Behavior. I think that maybe it can not be instance specific, that if I change anything about the Turret Behavior for one instance it will change the behavior for all instances regardless of how that change occurs?
B
11
S
4
G
4
Posts: 28
Reputation: 2,831

Post » Tue Jun 20, 2017 1:45 am

Case Closed
I was correct in my assumption that the Turret Behavior is incapable of having Instance Specific conditions, so I used an alternative targeting method and now everything is working as it should.

I appreciate everyone's input on this, although it ended up being an old "HomingMissiles.capx" example provided by Yann that gave me the solution I needed. It was from this thread: homing-missile_t68116

And thanks to cjbruce's input about the For Each condition, the Drones will not all target the same Asteroid/SpaceStation

Here is a screencap of the targeting method, in case it can be of use to anyone.
http://i88.photobucket.com/albums/k166/ ... bmvmqk.png
B
11
S
4
G
4
Posts: 28
Reputation: 2,831


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 32 guests