0 Favourites

Artificial inteligence for soldiers

  • Hi everyone,

    I again =)

    I'm trying to make one A.I. that attacks all enemies in its path. The problem is that the soldiers behave equals. I wanted them to behave individually. Can anyone give me a little help?

    Demo

    CAPX

    Thank you all

  • You can prevent this by using the "system for each" condition.

  • It would also probably be better to use the timer behaviour instead of the sytem every x seconds in this case.

  • I do not understand. I am already using 'for every x seconds' condition <img src="smileys/smiley19.gif" border="0" align="middle" />

    <img src="https://dl.dropboxusercontent.com/u/2064178/combat-test-construct.png" border="0" />

  • I think I said use the timer behaviour instead of every x seconds.

    every x seconds will be the same for all hero's because it's counted from layout start.

    Timer behaviour will make sure each hero has it's own time.

  • I understood. But I've no idea how make a timer for each 'hero'.

  • you can put a behavior 'Timer' in each 'hero'

  • Wow, I did not know existed this behavior. Now I've to learn how it works.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • I changed to 'timer', but they (the heroes) do not attack.

    <img src="https://dl.dropboxusercontent.com/u/2064178/timer.png" border="0" />

  • As a generic response. Good AI is darn difficult to make, even those huge budget AAA games often have quite bad AI characters that quite often do more harm than good. So, any easy/simple answer that would work on all situations ain't likely to be found.

    Addendum: For this particular case.

    I am not 100% sure what kind of game you are making.. so this my advice may indeed be totally useless to you.

    For starters I would consider making the scene grid and turn based, that way it would be easier to be sure that the heros and enemies would not stomp atop of each other and also all players on the field do their movements and attacks in manageable fashion.

    If you want them to have pixel (or sub-pixel) positioning, you'll need to define whom the characters want to attack? Perhaps the weakest enemy, or the closest or spice up with some randomness?. Also you'll must be sure that the characters won't get stuck (if movement fails)...

    Oh. I got the nasty feeling, there should be at least I more tutorial of this AI.

  • I agree...

    but in my case, should not be so hard to make the instances attack individually. I'm noob...

  • One thing I noticed is the twitching the hero makes after closing to enemy. I think it would be better to stop movement when hero is at the good attack range and tries to hit enemy. Only if enemy moves away or dies should the hero move again.

    PS: I did expand the previous message quite a lot after testing your code, I hope you noticed.

    One issue I think comes with the using Overlapping test alongside System (1.5 sec) delay causes problem. You'll most likely need to rethink that logic.

    I added one instance variable for each hero Cooldown and use it to delay the attacks and it seems to work better. Not perfect in any way, but didn't want to hack too much changes.

    Unfortunately I cant' copy the code as a text nor don't know how to add a direct picure. Scirra should really fix their system in a way that copy/paste works properly. <img src="smileys/smiley21.gif" border="0" align="middle" />

    Ah well. This forum systems needs tune-up anyhow, and I need to start using Dropbox anyhow..

    dropbox.com/s/8kderyrw5npvtz2/Clipboard02.png

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