Fast Gear – Week 7

In order to move the AI they have a force applied to their rigidbodies in the z-axis that pushes them forward. We use a property of the rigidbody called drag, which is how much air resistance the car will have when forces are applied to them. It is a scale from 0 to infinity where 0 is no resistance at all and infinity makes them unable to move. We are using drag to make the cars stick to the road better and the cars have their own value of drag so they have a different feel.

The problem this is causing is that they become so heavy when drag is applied and the player car can not push them out of the way. I tried removing the drag and give them each a physics material which is used to adjust friction between different objects. This was even worse and made the cars very slippery or too sticky, there were no in-between which is why I decided to go with the drag instead.

In order to make it seem like the player can push the other cars out of the way I made a script that checks if the AI has been hit by the car and then calculates the angle between the collision point and the player. We get the opposite Vector3 and normalize it and then add force in the direction of the impact. This will give the AI a nudge when it gets hit by the player. We will also implement so if the AI is directly behind the player they will slow down so they do not push you into a railing which can be very annoying.

About Simon Glans

2015 Programming