Enemy Tank AI

This forum is currently in read-only mode.
0 favourites
From the Asset Store
Try to destroy your enemies in a hard battle! Good luck!
  • Ah, that makes sense. But with more instances, Windows 7 will show more projects on Aero Peek.

    I'm sure you'll survive.

  • Ah, that makes sense. But with more instances, Windows 7 will show more projects on Aero Peek.

    And you're free to do that! Just don't copy anything from one project to another

  • Great, I fail to do the timer settings, because all the tanks rotate at the same time. I know it has something to do with the "Turn" Private variable. The link to the cap is still the same.

  • If pathfinding is the problem then I would suggest giving the enemy tank the RTS behaviour, you can set it so it moves around solids and such. The only drawback is that it's cell sizes for the path finding seem to be increments of 10 rather than multiples of 2, so it wouldn't quite line up for 32x32 size tiles for example. In any case, experiment with the RTS behaviour, you can do some cool stuff

  • Great, I fail to do the timer settings, because all the tanks rotate at the same time. I know it has something to do with the "Turn" Private variable. The link to the cap is still the same.

    Your event is picking all of the Tank instances. If you want each on it's own timer, then you should give each it's own timer.

    Make a "myTimer" private variable. On start of layout, do "For Each tank -> Set 'myTimer' to random(however long)."

    Then in the main movement loop do "For Each tank -> subract from 'myTimer' whatever amount." Then when the tank's timer is less or equal to zero, give the turn command and generate a new random amount for their timer.

  • Hmm, but the Turn Event is used to make the tanks turn around. They only have the bullet behaviour. That means, I would have to rewrite everything and also, it will only turn in one side and not randomly left or right.

  • I tried and I tried and I tried. I still can't get this stupid enemies to work, when there are two or more enemies.

    Can anyone help me with those stupid tanks, please?

    This is not a captcha. This is a .cap File

  • Rise up from the grave!

    Anyway, I now use the RTS Behaviour. I didn't know how to make him move randomly, so I just did this with the waypoint to put at x: random(640) and y: random(480).

    Now the issue is, how can I make that it doesn't put the point in the wall? The enemy sometimes just goes in circles because he can never touch the waypoint.

    If anyone has another way of random movement, than just post your idea.

  • I think this needs some better explanation.

    I made the enemies work with waypoints. Always when the enemy has reached the waypoint, a new waypoint gets added in the map.

    The event would be:

    If Enemy stopped moving

    ->Add waypoint at x=random(640), y=random(480).

    Now the problem would be, sometimes the waypoint would be added in the wall. Making the Enemy run in circles trying to go to the waypoint in the wall.

    Here's a little animation showing my problem:

    <img src="http://i41.tinypic.com/296c2ro.gif">

  • Add an event after the add waypoint event -

    + System: While

    + Waypoint: Waypoint overlaps Wall

    -> Waypoint: Set X to Random(DisplayWidth)

    -> Waypoint: Set Y to Random(DisplayHeight)

    So it will keep randomising the position until it no longer overlaps with a wall.

    Totally untested, but I think it should work. I've used a similar technique in other software, in the past.

    EDIT: Just looked a little deeper and realised your waypoint is not actually an object, but is an option on the RTS behaviour (which I've never used), so my solution above won't work. However, I'm confident the concept will work with a little tweaking - just use a 'while' to relocate the waypoint until a usable position is found. I'll see if I can come up with a proper solution.

  • GMG

    Here's a modification of your solution that should work.

    + System: While

    + System: "Solid" at (Sprite[RTS].DestX, Sprite[RTS].DestY)

    -> Waypoint: Set X to Random(DisplayWidth)

    -> Waypoint: Set Y to Random(DisplayHeight)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • GMG

    Here's a modification of your solution that should work.

    + System: While

    + System: "Solid" at (Sprite[RTS].DestX, Sprite[RTS].DestY)

    -> Waypoint: Set X to Random(DisplayWidth)

    -> Waypoint: Set Y to Random(DisplayHeight)

    Holy $#!^

    Wait, you can evaluate a sprites attribute?

  • [quote:2pn9fm58]+ System: "Solid" at (Sprite[RTS].DestX, Sprite[RTS].DestY)

    It's the System condition 'Object overlaps point'. And yes it works with an attribute instead of an object.

  • Wow. That's one for the wiki.

    Edit:

    Ok it works for move to position/ move to mouse, but not for waypoint.

    Just as well I guess, all waypoint does is ensure pathfinding around solids, and can actually bog down the system.

  • + System: While

    + System: "Solid" at (Sprite[RTS].DestX, Sprite[RTS].DestY)

    -> Waypoint: Set X to Random(DisplayWidth)

    -> Waypoint: Set Y to Random(DisplayHeight)

    If I use "While", then the app always crashes. Without While, it doesn't work (and the solution sounded so awesome).

    And there is no "Set Waypoint X" and "Set Waypoint Y". I only see "Add Waypoint to point" and "Move to point".

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