My Enemies can't take corners! Funny but very annoying!

Hello,

I've hit upon an interesting issue with my top-down maze/Gauntlet-esque type game I'm working on.
Here is what's happening;

In this pic you see the hero at the bottom and above him, separated by a wall, is an inactive enemy (i.e. at this point he just stands there and doesn't do anything.

Okay so hero moves to the right and stands on a trigger region, in this case I've left it visible so you can see it - it's the white rectagle. You'll now see that the enemy has come to life and is now charging with all his might towards the hero. He is configured to rotate to always be facing the hero and tries to move directly to his location;

Obviously as he moves along, nefore he gets to the hero he collides with the wall. Naturally, his movement down is prevented by the wall but he then continues to move to the right, which is good and exactly what I want - my expectation was that he would continue along that path until he reaches the gap, then he'd charge right at the hero, but instead he just goes skidding past the gap!

And he carries on until until he is stopped by the far wall;

If move the hero he charges back the other way but again, skids past in the other direction! I can coax the emeny to chase the hero if I move him while he is skidding past the gap, or if enter the room above the enemy homes in on him correctly, if he ends up directly in line with the hero in line with the gap then he does managed to follow, so the problems are to do with him hitting the wall.

The enemy's movement is being controlled by a Move To command - he's simply set to move to the x and y location of the hero at a speed of 200. I suspect the problem is that I'm also using the 'bounce if enemy collides with walls' command. I set bounciness to 0, have tried experimenting with denisty and friction of the enemy but nothing seems to make a difference. I think I've read that using move and bounce together causes issues?

I've been trying to come up with an alternative way to control the enemy's collisons with walls with a collide rule instead of the bounce setting.. I tried differentiating between a horizontal or vertical facing walls and restricting the movement only to the unblocked axis. This worked okay - until the enemy hit an intersection of both types of wall and simply stopped dead!

Can anyone suggest anything else?

Comments

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    @mysticjim, Move and Bounce should work fine in combination with each other. You might try using Accelerate Toward instead of Move To. I'm not certain that will work better but its the method I used in this tutorial:

    With Accelerate Toward though you'll probably want to set a max speed for the enemy and make that active in it's Actor Attributes or else it will likely end up speeding off screen. I do this in the tutorial as well.

  • mysticjimmysticjim Member Posts: 30

    Hi Jamie C - yes, that works a hell of a lot better than my design, very nice work. I do have one slight issue with the accelerate toward command. I don't mind the acceleration, but I do need more rapid changes of direction. When I make the hero do a sharp turn the enemies hurtle around the corner is a huge arc, and when they catch my hero actor they can't stop in time to attack him and have to turn around and come back! I've tried setting them to bounce off the hero, that resulted in them pushing along into the nearest wall. I added density and friction to the hero but it only improved it a bit didn't stop the issue altogether.

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    To get them to change direction faster try making the value of the Accelerate Toward behavior their max speed like I did in the tutorial. If their max speed is 200 set them to accelerate toward at 200 as well. That way they will change direction as quickly as they can.

  • mysticjimmysticjim Member Posts: 30

    Tried that - they still drift, it's like some kind of inertia in the physics engine. I've had an idea though, I reckon I can solve the issue by using move to when they going in a straight line, but switch to accelerate towards behaviours when they hit a wall. Could be interesting!

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    Let me know what you come up with. It's a tricky subject that is for sure, you may need to create your levels with their limitations in mind as well. Or think about incorporating a more robust AI routine.

  • mysticjimmysticjim Member Posts: 30

    Hi Jamie_ C. The method I mentioned has worked, the enemies successfully navigate corners and obstacles using your technique then make a bee-line straight for the hero once free of obstructions using Move To, and if they catch up with the hero they stop dead and give him hell!

    Your suggestion works perfectly on it's own at lower speeds, but I really want quite frantic action in my game, my hero moves fast but without inertia, and I wanted the enemies to move more or less in the same way. At those speeds, with your technique alone it resembled a scene out of the movie Fast and Furious: Tokyo Drift! The enemies never ended up engaging the hero as just went skidding past him! I should put a video up of it because it was actually hilarious!

    I think I'm happy with that, thanks again for your suggestion, it was critical to getting something that worked. In the end I feel like I've got the best of both worlds! Still can't figure out why the move to command on it's own produced the weird behaviour in the first place though.

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    Thats great, glad to hear you got something you like. Hurray for teamwork! :)

Sign In or Register to comment.