Cornering:
Before the car picks a new waypoint i.e. makes a turn it works out if it is a left turn.
If it is a left turn then it turns early, otherwise it turns late.
This can then be used for advanced stuff later.
Collision detection:
Now improved, casts a ray in front of the car and stops if stuff is in the way.
I put loads of cars in and most do well, the main problem is the crossroads.
Basically because they don't give way to anything, just stop if something's in front.
This is where the advanced stuff for turns can come in.
Sunday, 29 May 2011
Thursday, 19 May 2011
Unity car AI - with collision avoidance
Simple, simple collision avoidance.
Making better at the moment
Making better at the moment
Car AI Code
Hi, a couple of people have asked for code so here it is: Code
This is for the cars that try and avoid each other.
If you do anything cool with it, please let me know so we can make sure we're not both trying to do the same thing.
Wednesday, 18 May 2011
Even more car AI in unity
Code is now simplified, got rid of gears, neighbours are only searched for once at the beginning, corners are handled better now as well.
Also, if the car ever faces away from its destination it will find a new way round rather than reversing into the front of another car.
A couple of crashes with lots of cars but to be honest that's not too bad considering they all ignore each other. Next step is obstacle avoidance.
Tuesday, 17 May 2011
More Car AI
Some more car AI using Unity 3D using 1 waypoint for each corner.
this is the same as the previous video but using textured roads rather than those stupid cylinders.
A bit of trouble with the random start waypoints causing crashes - possible solution: spawn cars next to first destination
Some wide cornering, maybe due to time taken to find new destination - possible solution: pre-plan next dest when a bit further away, but still switch at the same point.
I can also speed this up by letting all waypoints know their neighbours once at the beginning of the script, rather than searching for them each time a car comes to them.
Monday, 16 May 2011
Start of Dissertation: Some car AI
Here's some car AI using Unity 3D using 1 waypoint for each corner. The hope is that after a while this should make a working traffic system.
Base code from here: http://www.gotow.net/andrew/blog/?page_id=78
The cars do settle into some nice motion at points, however the fact that thy all choose a random starting destination causes some crashes!
Slight tweakage should fix that.
I'll post code when its a bit more stable.
Base code from here: http://www.gotow.net/andrew/blog/?page_id=78
The cars do settle into some nice motion at points, however the fact that thy all choose a random starting destination causes some crashes!
Slight tweakage should fix that.
I'll post code when its a bit more stable.
Subscribe to:
Posts (Atom)