- Home /
How to use Vector3 int C#
Hello everyone ,i meet a problm. when i use javaScript like:
var pos =new Array
(
Vector3 (-1.8, 0, 0), Vector3(-0.6, 0, 0)...
);
it works. But in C#:
public Vector3[] haha=new Vector3[2]{Vector3 (-1.8f, 0, 0), Vector3(-0.6f, 0, 0)};
there are some problems . how to use Vector3 Array in C#
Answer by Paulius-Liekis · Dec 20, 2010 at 01:50 PM
I think this should work:
public Vector3[] haha = new Vector3[] {new Vector3 (-1.8f, 0, 0), new Vector3(-0.6f, 0, 0)};
Answer by spaceshooter · Dec 20, 2010 at 01:45 PM
There are probably a few ways to do it. I am a fan of ArrayLists...
ArrayList a = new ArrayList(); a.add(new Vector3(0,0,0)); a.add(new Vector3(1,1,1));
foreach(Vector3 v in a){ Debug.log(v); }
No reason to use an ArrayList here ins$$anonymous$$d of a generic list.
Same reason as Jessy, but also with the comment that it possibly isen't a good idea to use foreach, because don't they also use an extra test for checking the type? $$anonymous$$aking them more expensive than e.g. Paulius Liekis'.
Your answer
Follow this Question
Related Questions
Position in front of an object? 2 Answers
Script that allows me to spawn enemies in game. 1 Answer
Need help with rotation 4 Answers
operation between the Vector3 1 Answer
Vector direction for a reticle 1 Answer