- Home /
HELP!!! Expression denotes a `type', where a `variable', `value' or `method group' was expected
I'm really just a beginner lol, and not sure if there is anything wrong here...
using UnityEngine;
using System.Collections;
public class Wall : MonoBehaviour {
void OnTriggerEnter2D (Collider2D hitInfo) {
if (hitInfo.name == "Ball") {
string hit = "hit";
AddScore (hit);
//trying to call a function (Maybe this is where the problem is lol)
}
}
}
It tells pops an error out : Expression denotes a type', where a
variable', value' or
method group' was expected
I had to drop an 'AddScore' function into the class, but this code compiles fine (without the error you specify):
public class Wall : $$anonymous$$onoBehaviour {
void OnTriggerEnter2D (Collider2D hitInfo) {
if (hitInfo.name == "Ball") {
string hit = "hit";
AddScore (hit);
}
}
void AddScore(string score) {
Debug.Log (score);
}
}
Note the typical reason the "'type' where a 'variable'" error comes across the list is because the OP forgot the 'new' operator. That is in C# they did:
transform.position = Vector3(1,2,3);
Ins$$anonymous$$d of:
transform.position = new Vector3(1,2,3);
Answer by FatalVitality · Feb 18, 2014 at 07:47 PM
I think you'll need a variable for hitInfo in the same script
Your answer
Follow this Question
Related Questions
Expression denotes a 'type' 2 Answers
What is typing a variable? Is it assigning the value? 3 Answers
cant assign variables value 2 Answers