- Home /
What is the difference between declaring a Vector 3 and new Vector 3?
Hi, i'm new to coding so forgive my ignorance but I have been watching the Unity Learn tutorials and a few things in them are confusing me and making me feel like i'm going backwards instead of learning. In one of the tutorials a variable (I think) is created with the type "new Vector3", what I want to know is what does the new mean and how is it different. I'm also consufed about Classes and Arrays, but I will leave that for another day.
Thanks for the help, I love Unity and Designing games but scripting can be confusing sometimes :S.
Heya.. I'm not sure about, what does the "new" stands for Vector3, but for arrays, you can define the array length with the new. For example
var myArray : Transform[];
myArray = new Transform[10];
Here the myArray will be limited to 10 Transform elements and Unity is treating these arrays verry fast.
Answer by whydoidoit · May 17, 2013 at 02:52 PM
In C# when you want to create anything you put new in front of it. In Javascript in Unity you can omit it without encountering any problems. It just means create.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
How do I get one object to point toward another using rigidbody physics? 2 Answers
Convert local forward into world vector 1 Answer
Workaround for Quaternion.eulerAngles 360 Degree Limit? 1 Answer
Unexpected behavior on Vector3.moveTowards for Player 0 Answers