Hello, I’ve currently got a complex turn based game which I working on but I need a quick bit of help with this dilemma.
How do I find and then destroy a gameObject with a keyword in it?
I’ve got something like:
if (GameObject.Find(KeywordA in this name of the gameObject)) {
then go ahead and Destroy(this gameObject);
}
So if I have many objects named “TestingObject5 Movement=(A different random number)” and a few named “TestingObject4 Movement=(A different random number)”, and KeywordA is “TestingObject5”, it will destroy all the objects with the name of “TestingObject5 Movement=(A different random number)”.
var SceneObj : GameObject [];
function FixedUpdate () {
SceneObj = FindObjectsOfType(GameObject) as GameObject[];
}
function CreateTurnObj () {
for (var i=0; i < AllSceneObj.length; i++){
if(SceneObj*.name.Contains("Turn=" + TurnPlace)){*
print (SceneObj*.name);* }}} The one restriction is it can cause lag (i haven’t noticed it) if this is used on a scene with a lot of objects.