- Home /
AI not realistic...
This is my code, i have a car game where the enemy car tries to crash into you and other enemy cars, but the problem is... THEY START FLYING AT ME WHEN I DO A JUMP! and the also go too slow. and when i hit them (its a crashup type game) they start going crazy! can anyone give me some help? D:
var player: Transform;
var waypoint : Transform[];
var target : Transform;
private var distance: float;
private var currentwaypoint : int;
function Start() {
player = GetRandomPlayer();
}
function Update () {
distance = Vector3.Distance(transform.position, player.position);
if (distance > 1.5f) {
transform.rotation = Quaternion.Slerp(transform.rotation,
Quaternion.LookRotation(player.position - transform.position),
Time.deltaTime * 4);
transform.Translate(0, 0, .05f);
}
}
function GetRandomPlayer() : Transform {
var players = GameObject.FindGameObjectsWithTag("Player");
return players[Random.Range(0, players.Length)].transform;
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613070339im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Possible Bug with RPC calls (Unity 2.6) 1 Answer
Unity crashes because of script 2 Answers
_player = new Player(); *CRASH!* 2 Answers
Animation refuses to play 1 Answer