- Home /
little problem with java script
ok so ime making a Ai for a racing game and i nead the car to turn so i thought ide use the on enter function but the If statment aint working and the look at isnt working.
var target : Transform;
function OnTriggerEnter (other : Collider) { if Collider.name == "carAI" { Collider.transform.LookAt(target); } }
IF eror is
Assets/costom scripts/AI/AI turn 1.js(5,27): BCE0044: expecting ), found '='.
look at erors are
Assets/costom scripts/AI/AI turn 1.js(5,38): BCE0043: Unexpected token: ).
Assets/costom scripts/AI/AI turn 1.js(7,50): BCE0044: expecting :, found ';'.
Answer by Mike 3 · Mar 16, 2011 at 12:10 PM
There are a couple errors there, missing brackets and a typo
var target : Transform;
function OnTriggerEnter (other : Collider) { if (other.name == "carAI") { other.transform.LookAt(target); } }
Collider should have been other, and you were missing the parentheses for the if
thanks i realy strugle with progra$$anonymous$$g due to dyslexia