How do I Pathfind away from the player?

Get help using Construct 2

Post » Tue Oct 06, 2015 12:31 am

I don't quite follow the issue you're having.
When I tried out my idea it came out different than my post above after I tweaked it for a bit. Here it is:
https://dl.dropboxusercontent.com/u/542 ... trees.capx
It's still not perfect as the deer can run through the trees, especially when being chased.

The perfect solution would utilize this I guess:
http://gamedevelopment.tutsplus.com/ser ... edev-12732
http://www.red3d.com/cwr/steer/gdc99/
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Wed Oct 07, 2015 2:38 am

My problem is that I simply use this:
Every tick
--- deer: set angle to (player.x, player.y)
--- deer: rotate clockwise 180 degrees
And use a collision box that turns the object when it collides, so it looks like it turns away from it.

The problem I'm having though is that when the object is moving away with the bullet movement every second you will see it turn backwards towards the player for a split second due to setting the angle to the player constantly and setting it away. I make it change it's angle -180 degrees towards the player, basically turning away. It looks like it's spazzing occassionally due to this. Another big problem is that when it runs into a wall it turns, and runs along the wall. Because of it constantly turning away from the wall and the player at the same time it is very spazzy and I need a way to stop it from turning away from the player while next to a solid.

What i'm using to alleviate this right now is a large collision box that constantly spawns around the running away object when it has detected you. When it comes in contact with a solid I set the instance variable for it's turning away from the player 'off'. The big annoyance is that there isn't else or an invert option for collision events so I can't simply make it turn the turning away from the player back on when it's away from the wall. Each object that is running away has everything tied to instance variables so they work seperately.

Any way to fix this spazzing out? Thanks. :)
B
28
S
11
G
4
Posts: 77
Reputation: 4,321

Post » Wed Oct 07, 2015 3:11 am

Those two actions are run before everything is rendered. The spazzing is probably turning to abruptly.
Making the turning smoother can help. Instead of rotating by 45 rotate by a smaller value. And instead of setting the angle away from the player, use the the rotate towards action with a negative value.

The last issue you mentioned about it spazzing against walls will require another method than what I posted. I just handled single trees where it chose left or right of the tree depending on what was closer.
I only have a rough idea how walls could be handled. However I don't have any easy solutions at hand.
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Previous

Return to How do I....?

Who is online

Users browsing this forum: Rhindon, YoHoho and 23 guests