Need Help on this simple Script

hmmm trying to learn just at least basics of unity3d programming from time to time nothing super complex XD the really complex stuff ill leave that to the programmer

for now

well trying to make a simple enemy AI chase player or detect player (in this case if enemy detects player is close enough changes material color to yellow)

whats wrong in the script?

‪#‎pragma‬ strict

var Distance;
var target : player ;
var lookatdistance = 25.0;
var attackrange = 15.0 ;
var smoothing = 5 ;
var damping = 6 ;

function Start () {

}

function Update () {
distance = Vector3.distance(Target.position,transform.position);

if distance = distance > lookatdistance
}
{

Renderer.material.color = Color.yellow;

}

Edit: The Update() method is fubar, ref. the wrongly aligned brackets.

I agree with toreau … use code tag.
You are asking “what’s wrong in the script ?”. I’ve lost my magic … you tell as what’s wrong, what’s going on, what compiler sais, what line ( if there is ) causin’ error ? More information.

lines 18 and 19, you got your brackets backwards, also you want to place the color changing code inside those brackets, it’s currently after that code block runs, which means it’ll go yellow in any situation. Hope this helps! :slight_smile:

~
Another walk in the park.

“Bracket backwards”?

"distance = distance > lookatdistance " this condition doesnt seem right to me

What I meant was (and also Disolution is correct, didn’t spot that lol, was getting tired at the time), this block of code:
if distance = distance > lookatdistance
}
{

should look like:
if distance > lookatdistance
{
}

Brackets = { and }
Paranthesis = ( and )

Hope this helps! :slight_smile: