Hi! This is my first question but probably not the last. What I was trying to accomplish with this is to remove the gameobject from the array and destroy it when it collides with a specific object.
The commented line (global.arr.RemoveAt*;) is currently giving an error as follows:* *Type 'function(int): void' does not support slicing.
* *Which makes my head explode. I'm very noob. Is my loop wrong somehow? Is it syntax? Wrong array type for what I'm doing? I'm also not sure that comparing the position is the best way to verify I have the right object from the list. Any help is greatly appreciated!
* *```* *function OnCollisionEnter(theCollided : Collision){* *//when an object collides with something named ground* *if(theCollided.gameObject.name == "ground"){* *//set a variable to the number of entries in the array -1 to get last array entry* *var ii : int = global.arr.length -1;* *//loop through the array* *for(i=ii; i>=0; i--){* *//if the object on the list has the same position as the collided...* _if(global.arr*.transform.position == gameObject.transform.position){*_ _*//remove the object from the list*_ _// global.arr.RemoveAt*;*_ _*//print the new list for verification*_ _*Debug.Log(global.arr);*_ _*//destroy the object*_ _*Destroy(gameObject);*_ _*}*_ _*}*_ _*}*_ _*}*_ _*```*_
Wow! Seems like I wasted so much time. Thank you for your quick and helpful response!
– anon57816631