scripting error
I have been using: [http://www.instructables.com/id/How-to-make-a-simple-game-in-Unity-3D/?ALLSTEPS][1] to make a unity game and I have come across this error: Assets/Scripts/Character_Controller.cs(38,32): error CS1525: Unexpected symbol (', expecting
)', ,',
;', [', or
=' In the Void CountText () { section Unfortunately I have no clue what I have done/left out to cause this, some help is requested. if anything else is seen I would also appreciate it if you told me aswel Here is the script:
using UnityEngine;
using System.Collections;
public class Character_Controller : MonoBehaviour {
public float speed;
void FixedUpdate () {
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
GetComponent<Rigidbody>().AddForce (movement * speed * Time.deltaTime);
}
private int count;
public GUIText countText;
void Start () {
count = 0;
CountText();
}
void OnTriggerEnter (Collider other) {
if(other.gameObject.tag=="item"){
other.gameObject.SetActive(false);
count = count + 1;
CountText();
}
if(other.gameObject.tag=="hazard"){
other.gameObject.SetActive(false);
Vector3 jump = new Vector3(0.0f, 30, 0.0f);
rigidbody.AddForce (jump * speed * Time.deltaTime);
}
Void CountText () {
countText.text = "Count: " + count.ToString();
}
}
I thank you for the help
Answer by rutter · Nov 20, 2015 at 07:22 AM
Around this part:
void OnTriggerEnter (Collider other) {
if(other.gameObject.tag=="item"){
other.gameObject.SetActive(false);
count = count + 1;
CountText();
}
if(other.gameObject.tag=="hazard"){
other.gameObject.SetActive(false);
Vector3 jump = new Vector3(0.0f, 30, 0.0f);
rigidbody.AddForce (jump * speed * Time.deltaTime);
}
Void CountText () {
countText.text = "Count: " + count.ToString();
}
}
You're accidentally trying to define a function within the body of another function.
Every {
needs a matching }
so that they are "balanced". Each function must end before the beginning of the next one.
You may also need another }
to close the class, at the bottom of the file. I don't see one here, but that might just be a fluke of copy-paste.
Your answer

Follow this Question
Related Questions
Unexpected Symbol ' var' 1 Answer
unexpected symbol 1 Answer
Coding Error 1 Answer
Unexpected symbol 'float' 1 Answer