Quick C# Question - Variables in Other Scripts

'Nother quick one: I have a script, “CameraControlScript”, attached to the Main Camera that locks on to a Transform called ‘target’.

Now I am trying to make an object assign itself as the target for CameraControlScript. I currently have:

Camera.main.GetComponent<CameraControlScript>.target = transform;

But this throws

error CS0119: Expression denotes a `method group', where a `variable', `value' or `type' was expected

I’m missing another C# gotcha… Can someone help this hapless Javascripter out?

Thank you so much!

Camera.main.GetComponent().target = transform;

You forgot some parenthises.

D’oh! Forgot the parentheses.

Needs to be:

Camera.main.GetComponent<CameraControlScript>().target = transform;

Crazy C#!