How do I get AI to share information.

0 favourites
  • 2 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • 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?

    Condition: Enemy1 - has Line of Sight to Enemy1
           Action: Enemy1 - Set - PlayerPositionX to Enemy1.PlayerPositionX
                   Enemy1 - Set - PlayerPositionY to Enemy1.PlayerPositionY[/code:29fg396z]
    Obviously doesn't work because it's just affecting itself.
    
    Thanks in advance.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

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