I’m making the surviving island project from the book 3.X Development Essentials but I’m turning crazy about something:
I’m adding the trigger collision detection on the cells, and I have many problems and errors:
function OnTriggerEnter(col : Collider){
if(col.gameObject.tag == “Player”){
col.gameObject.SendMessage(“CellPickup”);
Destroy(gameoObject);
}
}
I wrote this code because it’s copied from the book but there are too many errors:
- Assets/Standard Assets/Character Controllers/Sources/Scripts/PowerCell.js(8,10): BCE0044: expecting (, found ‘OnTriggerEnter’.
- Assets/Standard Assets/Character Controllers/Sources/Scripts/PowerCell.js(8,25): BCE0043: Unexpected token: col.
- Assets/Standard Assets/Character Controllers/Sources/Scripts/PowerCell.js(8,25): BCE0043: Unexpected token: col.
- Assets/Standard Assets/Character Controllers/Sources/Scripts/PowerCell.js(9,1): BCE0043: Unexpected token: if.
- Assets/Standard Assets/Character Controllers/Sources/Scripts/PowerCell.js(9,35): UCE0001: ‘;’ expected. Insert a semicolon at the end.
- Assets/Standard Assets/Character Controllers/Sources/Scripts/PowerCell.js(10,41): BCE0044: expecting :, found ‘;’.
I don’t understand why because I’m a noob of programmation and this it’s my first project.
Could someone help me please ![]()