x


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 ';'.

more ▼

asked Mar 16 '11 at 12:07 PM

joseph b gravatar image

joseph b
6 4 8 12

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Mar 16 '11 at 12:10 PM

Mike 3 gravatar image

Mike 3
30.5k 10 65 252

thanks i realy strugle with programing due to dyslexia

Mar 16 '11 at 12:13 PM joseph b

Yea that'll make it hard. Good luck with it.

Mar 16 '11 at 01:51 PM Joshua
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3442
x112
x75
x34

asked: Mar 16 '11 at 12:07 PM

Seen: 769 times

Last Updated: Mar 16 '11 at 12:11 PM