Hi everybody! Recently, my friend and I finished a script what would count the number of enemies that were killed in a gladiator game we were making. However, we ran into one error in the code: a dialogue appeared at the bottom of the screen saying "error CS8025: Parsing error." Could someone please help me resolve this issue? I am inexperienced with coding. I have put the code down below. Thanks, sethestuff Code (CSharp): var int count = 0; function OnCollisionEnter (hit : Collision) { if(hit.gameObject.tag == Enemy)//if the enemy hit { count + 1; //add +1 to counter } GUI.Box(new Rect(10, 120, 50, 20), "Counter:" + count); }
GUI box component mustn't be in OnTriggerEnter. It should be in its own OnGUI function. Your main problem is with counter + 1. Replace it with counter += 1
Thanks for the help, but the error is still there. I have sent pictures to help you guys conceptualize the issue.
var count:int = 0; The way you wrote it is for C#, but ^ is the proper way for javascript. I don't use javascript much, but if you get an error with GUI.Box(new Rect(10, 120, 50, 20), "Counter:" + count); try changing it to GUI.Box(Rect(10, 120, 50, 20), "Counter:" + count); Remmember that .js files use javascript formatting, and .cs files use C# (C sharp) formatting.