I was making a go kart game and I need an opponent. is it possible that I use a follow track but when I touch the car it will affect him?
Here is a "simple" solution.
It involves two objects. A vehicle and a "waypoint jumper".
It is a kind of "Carrot on a stick" approach. The vehicle follows the waypoint . When the vehicle collides with the waypoint it jumps to the next waypoint location -> "waypoint jumper".
You are free to create an vehicle as you like. It needs to have two operations:
- move forward
- turn towards the waypoint jumper
here is an example:
I'm sure you have your own version of the vehicle. Just ensure it turns and moves forward all the time.
To make the vehicle detectable add a property
The type does not matter. It has no further purpose. It just should exist at the vehicle.
We need an object that can detect the vehicle from a certain distance. I suggest to use a mesh object that detects collisions with the vehicle. A plane or circle should be fine.
To avoid stopping the vehicle the object gets Physics type
When you have the object you can define the waypoints. Create an action with location keyframes at subsequent frames (1,2,3,4...). You do not need fine granularity. Just ensure the direct line between waypoints is not blocked and there is enough space for turns.
The jumper should know what the current waypoint is. We store it as property 'frame' a whole number, starting with the first frame.
First we play the current waypoint position. We do not need to do that all the time - only on startup or when the waypoint changes. We let the waypoint jumper play the pose according given by the property
When the car comes near we switch to the next frame. If the car happens when it collides with the mesh. We filter collisions by property
car, to exclude any accidental collisions with other objects.
Now you can start your game engine and watch your vehicle follow the carrot ... waypoint jumper.