How do I create 'race manager' movement without overlap

Get help using Construct 2

Post » Sat Aug 12, 2017 5:09 pm

Hi,

I am looking to create movement like the popular game 'race manager'. I have used the path finding example so far and played with this to get a good movement for a single car around the track. If I add extra cars when they overlap they pass through each other. I am looking at if its possible to have the cars go around each other like cars would on a real track?

So far I've tried bullet bounce or custom movement 'push' which I found in a thread but neither seem to work.

Thanks,
B
38
S
11
G
1
Posts: 204
Reputation: 4,477

Post » Sat Aug 12, 2017 5:17 pm

Don't think about it in terms of collisions - trying distance measurements instead. If car A is closer than X pixels to car B, attempt to go around it by speeding up/slowing down car A.
B
89
S
47
G
25
Posts: 535
Reputation: 21,827

Post » Sat Aug 12, 2017 8:13 pm

Hi @digitalsoapbox

I was hoping for both cars to keep their existing speed and for the quicker one to move out and overtake it as it passes.
B
38
S
11
G
1
Posts: 204
Reputation: 4,477

Post » Sat Aug 12, 2017 8:30 pm

Mayfly wrote:Hi @digitalsoapbox

I was hoping for both cars to keep their existing speed and for the quicker one to move out and overtake it as it passes.


After checking for distance, you could then pick the car with the higher velocity to execute the actions on.
B
89
S
47
G
25
Posts: 535
Reputation: 21,827

Post » Sat Aug 12, 2017 8:40 pm

I'm not sure there is an easy solution. You could look into steering behaviors as used in boids for a possible solution.
You could also take digitalsoapbox's idea to detect what's around the car and then use a state machine to decide what the car will do.

Like if it is clear in front of the car have it accelerate and drive in the best path.
If a car is in the way, have the car try to steer around the other. If the other car then slows then have the first car stop overtaking and move to the best path.

Basically look at what's around the car moment by moment and have states like "overtake" for maneuvers that take longer. It can get as complex as you want.
B
94
S
33
G
118
Posts: 5,396
Reputation: 75,853


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests