Hello, what i’m trying to do is add a object to a static array of transforms. The reason i’m doing this is because i made a grid of planes 68x68 grid. and when i click on a specific plane it will add it to the array. I know i create it like:
static var BList : Array[];
I’m just not sure how to add a object to it from my other script.
//static script-holds planes
static var grid : Transform[] = new Transform[68];
static var gridcount : int = 0;
function Add(item : transform)
{
if(gridcount < grid.length)
{
grid[gridcount] = item;
gridcount++;
}
}
...
//any other script
//this one is more pseudo code
function Onclick()
{
//use raycast rayhit system to identify temp-you can find on this site
var temp : Transform = clickedobject;
staticscriptname.Add(temp);
}
I hope this helps, to give you an example. Anybody feel free to comment if more needs to be added for the execution. If a variable is static you only need to reference the name of the script. Add could even be in the any other script and referencing grid & gridcount as staticscriptname.grid & staticscriptname.gridcount respectively. Anybody feel free to comment on my post if you think I missed something.