- Home /
Help with AI car physics
I'm making a game with AI cars chasing the player. Sort of like "smashy road" if anyone played that. I have this script below on my AI cars and it works fine but its rather boring. The cars just rotate towards the player and move toward it. Is there any way to spice it up with some drag on the cars or more realistic turning. I would do it myself but I am just learning to code. Thanks in advance.
public Transform Player; int MoveSpeed = 15; int MaxDist = 10; int MinDist = 5;
void Start()
{
}
void Update()
{
transform.LookAt(Player);
if (Vector3.Distance(transform.position, Player.position) >= MinDist)
{
transform.position += transform.forward * MoveSpeed * Time.deltaTime;
if (Vector3.Distance(transform.position, Player.position) <= MaxDist)
{
//Here Call any function U want Like Shoot at here or something
}
}
}
Answer by rhapen · Oct 24, 2020 at 06:22 PM
Look at this https://github.com/yasirkula/UnityBezierSolution I think its perfect for moving ai cars with curves and easy to setup paths. And free.
Your answer
Follow this Question
Related Questions
Tile generator only spawns one tile. 0 Answers
Problems with AI script 2 Answers
Spaceship AI for 3d game 1 Answer
Outline Shader not working correctly on blender models 0 Answers