- Home /
Is there an easy way to add an array of raycasthit2Ds to a list? (javascript)
I have been using this:
var hits : RaycastHit2D[] = Physics2D.LinecastAll (value, value);
But I'm slowly learning that the built in arrays in javascript suck and I'd like to be able to use some of the functions that a list has instead. Is there a nice (not memory intensive) way to convert the array of RaycastHit2Ds to a list?
I wanted to use the join function, but that doesn't seem to be a function of the built in arrays.
Thankyou!
Romano
Comment
Best Answer
Answer by Eric5h5 · Apr 19, 2014 at 04:41 PM
var hitsList = new List.<RaycastHit2D>(Physics2D.LinecastAll (value, value));
Answer by Romano · Apr 19, 2014 at 04:26 PM
Best I've got so far:
var hitsList : List.<RaycastHit2D> = new List.<RaycastHit2D>();
for (var a = 0; a < hits.length; a++)
{
hitsList.Add(hits[a]);
}