|
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][1] 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 [1]: http://answers.unity3d.com/questions/60191/arraypush-for-vector3-or-how-to-add-items-to-vecto.html125
(comments are locked)
|
|
in your first code, just replace positions with: that way, you can keep you var names. and that will work.
(comments are locked)
|
|
You can use "Array" (http://unity3d.com/support/documentation/ScriptReference/Array.html) Hi, I think this doesn't work. I'm running another function that will utilize the vectorArray[i] as a parameter. However, the parameter is set to a Vector3 type, and I think this type of array is just an Object type? Unity spits back: "The best overload for the method (..UnityEngine.Vector3)is not compatible with the argument list (..Object). Thanks for your help though!
Jun 30 '11 at 08:47 AM
coryl
Array is slow and not statically typed. List is much better.
Jun 30 '11 at 03:42 PM
Eric5h5
I never use array. Work in C# anyways.
Jun 30 '11 at 04:49 PM
GuyTidhar
(comments are locked)
|
