How do I make an enemy have "bad aim"

0 favourites
  • 10 posts
From the Asset Store
Pixel Enemies for SHMUP consists of 45 enemy ship sprites to be used in your game.
  • I currently have an enemy that always faces toward the player and shoots a burst of bullets every so often. This works ok but I would like to add some variety and randomness in the bullets to make it more interesting. I'm seeking advice on what would be the best way to do this.

  • You can add a random number to the bullet's angle of motion.

    It could be a simple random(-15,15) on every shot, this will make bullets to fly in 30 degrees cone.

    Or you can do something more complex like this:

    choose(0, random(-5,5), choose(-1,1)*random(20,30))

    This will make some shots 100% accurate, some not too accurate and some very inaccurate.

  • Also, you could use dop2000 solution, which is perfect, together with a instance variable for the enemies, like "skill", so you could set the range of accuracy for each enemy individualy and it would be consistently bad, good or average, for the whole of his existence in the game. This way you could even improve a enemy's skill whenever he hit the player or survived an encounter, making it look like they're learning and improving.

  • brunopalermo

    Thank you, I had never considered something like having an enemy have a skill level and even learning and improving as the game goes on. I will definitely be using this.

    dop2000

    Thanks for both examples. I really like the complex one, that is going to come in very handy.

    I have one problem though and it's probably something very simple about angles that I'm overlooking. Here's what I'm using below:

    When I have 'enemybullet's behavior at 'set angle=no' the bullets shoot out with the random cone just how I want it but not towards the player.

    When 'set angle=yes' the bullets shoot toward the player but it ignores the set bullet angle action and the shots remain in a straight line.

    What am I doing wrong here?

  • Could you share the capx, so I can reproduce the error and do some testing?

    Cheers!

  • Yes, here is a capx highlighting the part I'm working on.

    https://www.dropbox.com/s/5ubpw0l5vp7ce ... .capx?dl=0

  • Keep "Set angle=Yes" in Bullet properties and replace "Enemybullet Set Bullet angle of motion..." with this:

    Enemybullet -> Set Angle to (self.Angle+random(-15,15))

    So when a bullet is spawned, its angle is initially the same as enemy's angle. Then you adjust it by random number of degrees. And then it will fly in that direction because of "Set angle=Yes" setting.

  • Perfect. Thank you dop2000.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • And here's an example with a simple skill system. I added 2 more enemies and their skill levels are 10, 25 and 75. You can tweak the values and see how precision changes. Precision will also decrease automatically with distance since a small deviation at the end of the gun means a bigger deviation the further the enemy is, which is pretty realistic. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    https://www.dropbox.com/s/40ukw8mlhxql0 ... .capx?dl=1

    Cheers!

  • Very cool. Thanks for taking the time to do that brunopalermo.

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