TLDR: Anyone have a working solution for inserting Vector3's into an array?
Hello friends, I'm trying to build a Vector3 array to store a bunch of locations. I started by simply using
However, I soon learned that you can't use .Push or .Add with Vector3 for whatever reason. So I searched and found this solution: [http://answers.unity3d.com/questions/60191/arraypush-for-vector3-or-how-to-add-items-to-vecto.html]
So I tried using his first sample code:
However, Unity would give errors regarding an "Unexepected token" for the period on
There were no errors on this code, however for whatever reason, this doesn't actually insert data into the positions array! I checked that the item parameter is passing through successfully on AddItem(), and it is. So its just not being stored in the array for whatever reason.
If anyone has a working solution to this, would be much appreciated! Thanks : http://answers.unity3d.com/questions/60191/arraypush-for-vector3-or-how-to-add-items-to-vecto.html125
asked Jun 30 '11 at 07:49 AM
in your first code, just replace positions with:
that way, you can keep you var names. and that will work.
You can use "Array" (http://unity3d.com/support/documentation/ScriptReference/Array.html)
answered Jun 30 '11 at 08:16 AM