Artificial intelligence

0 favourites
  • 3 posts
From the Asset Store
High quality sound effect pack, in the following categories: computer voice
  • So, I need some help creating AI for my game. I'm going to include my .capx so its not so confusing. Basically, I need the enemies (which are brown tanks) to rotate towards the player(Big green tank) and then shoot at the player. I got the shooting part figured out, but the rotating is not working. I've already tried an attempt at this, but its not working so good. The problem I faced with it was that I couldn't implement it to other enemies in the game. Also, the way the sprites are drawn are throwing me off.

    So if anyone can figure out how to make this and be able to transfer easly to other enemies, I would be happy     <img src="smileys/smiley1.gif" border="0" align="middle" />

    P.S I'm using the battlefield art pack that is included when you buy construct 2 standard license.

    The project

  • 1\ System condition doesn't pick (unless it's a foreach, a pick nth instance, or a pick random instance)

    2\ You use a global variable to carry the direction, thus applying the same value for everyone

    Things could be waaaaaay simplier:

    +Enemy: Is on-screen
      -> Enemy: set a to ceil(((angle(self.x,self.y,player.x,player.y)+360)/45)-0.5)%8
      -> Enemy: set animation to "direction_"&a
      +System: Every 3 seconds
      +System: For each Enemy
        -> Enemy: Spawn Ts on layer 4 at image point "shoot1"
        -> Ts: set bullet angle to Enemy.a*45 degrees
        -> Audio: Play Explosion1 no looping (tag:"")

    These few line should replace your "AI_AimAtAngles" and "AI_ShootWhileonScreen" groups

    Note that you'll have to create an instance variable named 'a' type number for your enemies

    And also rename your animations:

    • right -> direction_0
    • rightdown45 -> direction_1
    • down -> direction_2
    • .. etc (respect the clockwise rotation)
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Wow! thank you so much! Exactly what I needed<img src="smileys/smiley4.gif" border="0" align="middle" /> I knew there had to be a simpler way of doing the aiming <img src="smileys/smiley17.gif" border="0" align="middle" />

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