light.color change on trigger enter

Hello World I have a problem with programming my Top-down zombie game. I’m trying to change the color of a point light from white to green when the zombie prefab enters the trigger on the Human object. I’m new to unity so I figured using Unity Answers was the way to go when finding help. I have my failed attempt of coding attached with screenshots of the console and project view to help make sense of my problem.

> // Turns human to zombie script
light.color = Color.white; // original human color
function OnTriggerEnter (other : Collider) // zombie collides with human then turns to zombie color
		if(other.gameObject.name = "Zombie");{
    	light.color = Color.green
}

You are not having a Unity problem but a programming problem. If statement does not take semi-colon. (Just saw that one yesterday here…) but it takes a { to start it.

Also, = and == are different. = assigns when == compares.In a if-statement you use comparison so ==

Finally, if you turn it green, you also need to turn it back when leaving the zone.

function OnTriggerEnter (other : Collider) // zombie collides with human then turns to zombie color
       if(other.gameObject.name = "Zombie");{
        light.color = Color.green
}

becomes

function OnTriggerEnter (other : Collider) {
       if(other.gameObject.name == "Zombie"){
            light.color = Color.green
       }
}
function OnTriggerExit (other : Collider) {
       if(other.gameObject.name == "Zombie"){
            light.color = Color.white
       }
}

You should be good to go now. :slight_smile:

http://gamejolt.com/games/shooter/undead-pixel/10316/