How do I get AI to share information.

Get help using Construct 2

Post » Mon Dec 08, 2014 1:56 am

Maybe I'm stuck on this because I'm lacking sleep but either way I feel pretty dumb right now.

Working on a top down action game with some stealth mechanics.
I have an enemy called Enemy1
When it sees the player with the line of sight behaviour, it sets its own state to "Attacking" via an instance variable.
While it's in the "Attacking" state (and the player is still within it's line of sight) it will record the players position via two other instance variables called "PlayerPositionX" & "PlayerPositionY"

I would like Enemy1, when in range of other Enemy1 instances, to share the players position to these other instances.
The goal is that the other instances of Enemy1 will join in attacking the player, but only once they have been alerted to the players presence.

I'm having trouble making one instance of Enemy1 do something to another instance via the event sheet.
How do I do that?

Code: Select all
Condition: Enemy1 - has Line of Sight to Enemy1
       Action: Enemy1 - Set - PlayerPositionX to Enemy1.PlayerPositionX
               Enemy1 - Set - PlayerPositionY to Enemy1.PlayerPositionY

Obviously doesn't work because it's just affecting itself.

Thanks in advance.
B
4
Posts: 8
Reputation: 221

Post » Mon Dec 08, 2014 2:39 am

I seem to have worked it out for myself.
I set a sub event condition picking the instance of Enemy1 in the attacking state then added the required values to an array.
Another sub event condition picks the other instances of Enemy1 (which aren't in an attacking state) and pulled the required values into its own instance variables.

It appears to work but needs a bit of tweaking.
Does this sound like the right way to go about it? I saw the Pick nth Instance but not sure if that'd be better.
B
4
Posts: 8
Reputation: 221


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 3 guests