Hi all,
Assets/kill.cs(20,25): error CS0119: Expression denotes a type', where a variable’, value' or method group’ was expected
I looked this up but can’t understand the replies to other peoples problems. Something about creating a “new” but not really sure what is meant to be new. I am trying to add a kill count to my GUI. I already have a count for collecting coins.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class kill : MonoBehaviour {
private int countKills;
public Text countKillText;
void Start ()
{
countKills = 0;
SetCountKillText ();
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag(“killTag”))
{
destroy(other.gameObject);
countKills = countKills + 1;
SetCountKillText();
}
}
void SetCountKillText()
{
countKillText.text = "countKills: " + countKills.ToString ();
}
}
Thanks for any help
[code ][/code ] tags when pasting code into the forums please, sticky at the top of the scripting forum on them.
Unity is case sensitive
Destroy(…)
not
destroy(…
thanks loads. looked at this for ages and got nothing. I can’t really understand when to use different cases is hteir a tutorial about this anywhere?
There are naming conventions for every programming language. However, the Unity API does not always match those exactly, they have some differences but they’re consistent in the Unity API.
This doesn’t mean you have to follow that pattern, you can also use your own ‘style’ for the namespaces, classes, variables, methods, properties etc that you create yourself which i wouldn’t recommend though.
In order to help with that, many Editors offer auto-completion. It’s often enough to know a part of the name you’re looking for. MonoDevelop should also support that quite well even though it sometimes seems to have issues with that.
An alternative professional IDE is Visual Studio from Microsoft, for example.
1 Like