Formatting Help

So I want the script to check ‘go’ and see if it has MouseLook enabled. If it does not, the script should turn it on.

If it’s on, it should do nothing.

This is the code I’ve been fighting with. I know there has to be some formatting error here that’s just beyond my skills. Could I get a little help on my syntax? Thanks!

if
		 	(go.GetComponent("MouseLook").enabled(false)){
		 	go.GetComponent("MouseLook").enabled=true; 
		 	}
if (!go.GetComponent("MouseLook").enabled) {
   go.GetComponent("MouseLook").enabled=true;
}

Alternatively:

if (go.GetComponent("MouseLook").enabled == false) {
   go.GetComponent("MouseLook").enabled=true;
}

Awesome. Thanks much.

That kind of thing isn’t really in the documentation anywhere, and I kind of have to discover them through tearing apart other people’s scripts. Slow going for us artist folks.

I really appreciate your help!

So, update on this. I modified things just a bit to be:

	if (!Maincamparent.GetComponent("MouseLook")){
			Maincamparent.transform.rotation = Quaternion.identity;
			Maincamparent.AddComponent ("MouseLook");
		}

Thinking that this would tell it to go see if it could find the MouseLook component on Maincamparent - and if not, to orient the camera, and add MouseLook again.

Unfortunately, it’s orienting the camera even if MouseLook is already there…it’s ignoring the ‘if’ part.

What am I doing wrong?