Noob Question

Hey all,

So I just started using Unity today. I have a pretty decent understanding of C++ but am still adjusting to C# (also just started today haha)
Anyways, I can’t figure out why whenever I use a command like say:
var EnemyPrefab : Transform;

it gives me an error that it was expecting a ; where the colon is
Is there a header I need to include or something?

Thanks all!
:smile:

JavaScript/UnityScript:

var EnemyPrefab : Transform;

C#:

Transform EnemyPrefab;

You can find many code snippets in the scripting reference. This one looks like the one you need:

At the top left, you can change the language.

So essentially Transform declares it as a certain type of object?
Still trying to wrap my head around this haha, used to transform being a function x)

So here’s my code:

	public void OnTriggerEnter(Collider collider){
		Transform EnemyPrefab;
		lives -= 1;
		Destroy(collider.gameObject);
		Instantiate (EnemyPrefab, new Vector3(0, 0, 0), Quaternion.identity);

I know I could technically just reference collider in instantiate but that doesn’t seem very practical for future use and am trying to get the hang of assigning variables and such in this language

Thanks again

There are a lot of official tutorials where you can learn the concepts of Unity and also to understand the scripting in it:

Beside that, you find tons of tutorials on YouTube and at other places.