Hi everyone,
In my program, I have a variety of game objects sitting on a plane. They’re all tagged with unique names.
The camera is top-down view.
I can “select” multiple objects by clicking and dragging my mouse around the objects (lasso effect). By clicking and dragging, the program creates a transparent 3D polygon to match the motion of the mouse. The 3D polygon has MeshCollider.IsTrigger active.
So if I have an object tagged “Cube”, and it’s inside this 3D polygon, I can use the following function to get its tag.
OnTriggerStay (col : Collider)
{
Debug.Log(col.tag);
}
I now have “Cube” being printed in my log every update.
Similarly, if I lasso 3 objects, “Cube”, “Sphere”, “Pyramid”, I now have “Cube”, "Sphere, “Pyramid” being printed in my log every update. I would like this to only be printed once per lasso.
I cannot use:
OnTriggerEnter()
OnTriggerExit()
At no point are these objects entering or leaving this 3D polygon. Nothing gets triggered this way.
So I have to stick with:
OnTriggerStay()
I cant do the following either:
//////////////////////
//SelectionScript.js//
//////////////////////
static var allowTrigger : boolean = false;
//Gets turned on from another script (Once every time the 3D polygon mesh is updated/created)
function OnTriggerStay(col : Collider)
{
if(allowTrigger)
{
Debug.Log(col.tag);
allowTrigger = false;
}
}
This won’t work because lets say I lasso “Cube” “Sphere”, and “Pyramid”. “allowTrigger” will get turned off after “Cube” is printed. I would need to turn it off after all 3 are printed.
Also, I have duplicate objects in my game. So at some point “Cube” “Cube” “Sphere” could be lassoed. Just a heads up in case it affects suggestions.
Any thoughts?
Alex