- Home /
';' Expected, Tried everything. How do I do this?
UCE0001 ';'. Insert a semicolon at the end.
JavaScript
var OnTriggerEnter(Collider) { AddScore(int) { SumScore.Add(_int); } }
What are you trying to do here? Don't take this the wrong way, but your code makes no sense. Are you trying to define functions you can call or call already defined functions within the OnTriggerEnter method.
Looks like you should probably brush up on JavaScript basic program$$anonymous$$g and syntax. I would recommend you scrap JS and move to C# though.
Answer by Hotshot10101 · Jul 13, 2017 at 09:23 PM
You need to start the line with function not var.
From the documentation here is an example:
// Destroy everything that enters the trigger
function OnTriggerEnter (other : Collider) {
Destroy(other.gameObject);
}
Hey sorry to bug you again, but I am getting this error again now
function OnTriggerEnter(Collider) { return addScore(int) { SumScore.Add(_int) { Destroy(other.gameObject); } }
You keep trying to define functions inside other functions. $$anonymous$$eep in $$anonymous$$d this is NOT javascript, but unityscript, which only looks like javascript.
You need to create a seperate AddScore
function.
function AddScore (increment : int) {
SumScore.Add (increment);
}
function OnTriggerEnter (other : Collider) {
AddScore (/*Whatever score goes here*/);
}
Tried it, fixed that problem, I now have an unknown identifier
Your answer
Follow this Question
Related Questions
; expected insert semicolon at the end 2 Answers
js(9,31): UCE0001: ';' expected. Insert a semicolon at the end. 2 Answers
UCE0001: ';' expected. There is one there? 1 Answer
UCE0001 error Insert a Semicolon at end 1 Answer
UCE0001: ';' expected. 2 Answers