Immediate Window Errors

Greetings. I’m a C# developer and new to Unity. I’ve an issue with using the the Immediate Window. I don’t understand what I’m missing in the following code and the errors returned.

(This works)
var velocity = Vector3.forward

(But this returns error)
var velocity = Vector3(0.0, 0.0, 1.0)
Evaluation failed.

I’ll also get “EOF expected” error on various modifications of the above code.

Thanks in advance.
Matt

Well, you have two errors in your line of code:

  • To create a Vector3 value you have to use the new operator.
  • Vector3 only accepts float values as parameters to the constructor. A double value hast to be casted into a float value as float has less precision.

This should work:

var velocity = new Vector3(0.0f, 0.0f, 1.0f);