Problem with copying array that holds Raycasthit objects

Posted: Fri May 14, 2010 2:34 pm Post subject: Copying an array

it doesn’t seem to work…

here is how i tried to do it:


  var hitObjects : Collider[];
  var hits : RaycastHit[];

copying the array after some objects were hit:


     for (i=0;i<hits.length;i++) { 
          hitObjects _= hits*.collider;*_ 
_*<p>later on i wanted to verify is everything is ok with this in OnGUI function but i get info only for hits[x] not for anything else: </p>*_
 _*for(var x=0;x<hits.length;x++){*_ 
 _*for(var y=0;y<hitObjects.length;y++){*_ 

Do a check, have you initialize the starting length for the hitObjects array?

After seeing comment: You have to use a Javascript Array, or an ArrayList, which supports dynamic size. You can take a look at this page

Or when using fixed size array

hitObjects = new hitObjects[hits.length];