- Home /
It is not possible to invoke an expression of type 'UnityEngine.GameObject'?
Here is the code I am learning with. I have no clue why this error is happening. I followed the tutorial 100%. Please help!
var cameraObject : GameObject;
var rotateSpeed : float = 0.3;
var holdHeight : float = -0.3;
var holdSide : float = 0.5;
private var targetXRotation : float;
private var targetYRotation : float;
private var targetXRotationV : float;
private var targetYRotationV : float;
function Update () {
transform.position = cameraObject.transform.position + (Quaternion.Euler(0,targetYRotation,0) * Vector3(holdSide, holdHeight, 0));
targetXRotation = Mathf.SmoothDamp(targetXRotation, cameraObject(MouseLookScript).xRotation, targetXRotationV, rotateSpeed);
targetYRotation = Mathf.SmoothDamp(targetYRotation, cameraObject(MouseLookScript).yRotation, targetYRotationV, rotateSpeed);
transform.rotation = Quaternion.Euler(targetXRotation, targetYRotation, 0);
}
Answer by Fattie · Sep 05, 2012 at 08:34 AM
looks like a problem w/ MouseLookScript,
perhaps you forget GetComponent ?! :) hope it helps in some way
Incidentally this is a good tip ..
when you get that confusing error "not possible to invoke an expression..."
Essentially - what it means is "syntax error".
Almost always, it just means you've forgotten something ...
you've forgotten an equals sign
you've forgotten a plus sign
like here, you've forgotten something like "GetComponent"
you've forgot the word "function" in front of where you give a function.
It's really quite annoying and a trap for beginners. It sort of has "nothing to do with" invoking an expression whatever. (Only if you're a very advanced programmer, or you write parsers or whatever, will you particular see what the error really "means".)
So whenever you see that particular error, in short, assumed you have forgotten something, you've left out part of a line of code (often a plus sign, or similar).
Your answer
Follow this Question
Related Questions
Setting Scroll View Width GUILayout 1 Answer
press e to speek -1 Answers
Error Unexpected token } 1 Answer
"Expecting ), found ';'" and "';' expected. Insert a semicolon at the end" 1 Answer
Can someone help me fix my Javascript for Flickering Light? 6 Answers