Make duplicative AI skills

0 favourites
  • 6 posts
From the Asset Store
Set of 200 hand drawn skill icons. All icons are of a high quality.
  • Hello world! :D

    I am trying to make AI similar to 'http://www.verygaming.com/action/strike-force-heroes' and it's going pretty well so far.

    This is the situation:

    I have a main player sprite

    I made hands with a gun positioned to player's shoulder, and which rotate in the player's direction if player is spotted.

    I also made a sprite for the line of sight (to see if enemies see the player trough walls) which is also positioned to player's shoulder.

    Then I made variables to the 'Line of Sight' for firing On/Off to make some bullets shoot when player is spotted.

    There is no problem until I wanted to make more than one enemy of this type on stage: because I want hands to remain calm if player is not spotted, and line of sight has to follow him all the time, I cannot make it the same object.

    And for example: Line of sight (enemy1) has Variable to "On" (means it spotted the player), all the hands read that variable and turn to the Player.

    If I could just somehow make a single complex enemy who can be duplicated and maybe edited independently without having to make all the sprites all over again. Like a group or something, so that it has the same sprites, but not to read one another's variables.

    I hope you understood my problem, I am not that great in Englis, but I gave my best to describe it to you.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I had this exact problem and what fixed it was making a 'For each' loop. So:

    For each 'enemy' + line of sight 'On' > Rotate towards player + fire bullets + etc.

    It was thankfully a very simple fix for me. If you still have trouble I will try to post a capx for you.

  • Thank you for a quick reply!

    I tried what you suggested, but no luck... They still all look at the player as soon as the first line of sight is active. I tried all the combinations with 'For Each' action, even tried something with groups, but they can't tell the difference between their line of sight and someone else's, so they always look at the player as soon as one of them has Line of Sight set to "On"

    I could try your .capx if it's not a bother for you to upload it

    Cheers! <img src="smileys/smiley41.gif" border="0" align="middle" />

  • You could set them in a family and if one is in line of sight you set an instance variable up. You just need to choose the right children with something like:

    -On line of sight collide(is over or anything else)

    with family -> family.insight = 1

    If you grant me your .capx I can do that for you.

    But you could also sell it as a feature :D

  • I checked out the families, and I think it wouldn't work that way either :/ But if you think you can figure something out, you could try it on this scirra.com/forum/c2enemy-line-of-sight_topic45095.html

    If I could just make the "Enemy" object read only Variables from "Line Of Sight" objects connected to him alone, and not from the same "Line Of Sight" object that is connected to another "Enemy".

    I could make it work for one and only enemy, but if I would like to duplicate him, it would all be messed up. Can I somehow limit Variables to only one group of objects, even if there are more than one instances of the same group?

  • You can make a variable in your 'LOS' object and call it something like "parent". When the 'LOS' objects are created, set the variable in each object to the UID (unique ID) of the correct 'Enemy' object. This way you can link the 'LOS' object to the 'Enemy' object and later use the variable to make sure the events only run for the correct enemy by comparing the variable and UID.

    +For each Enemy
    [ul]
    	[li]> Create object LOS on Enemy.X, Enemy.Y[/li]
    	[li]> Set variable parent to Enemy.UID

    I made this example for someone yesterday, it's not about LOS specifically, but it covers the parenting principle:

    EnemyHealthText.capx (r111)

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