Heyho
I have this void in Script A which should destroy previsously spawned gameObjects:
public void PickedUp(GameObject pickupCollected)
{
// retrieve name of the collected pickup and cast to int
int index = int.Parse(pickupCollected.name);
// pickup has been destroyed so make the spawn index available again
spawnIndexAvailableList[index] = true;
// destroy the pickup
Destroy(pickupCollected);
// spawn a new pickup
//SpawnPickup();
}
}
Now i have Script B which i put on the prefab of the spawned GameObjects. There is this void which shoud call the function PickedUp from ScriptA and pass the pickup that gets hit as the parameter for the void.
public void OnTriggerEnter(Collider collider)
{
if (collider.gameObject.tag.Equals("Player") && gameObject.tag.Equals("Pointbonus"))
{
Counter.Points += 100;
//Destroy(gameObject);
picked.PickedUp(gameObject);
}
if (collider.gameObject.tag.Equals("Player") && gameObject.tag.Equals("Faster"))
{
PlayerMovementController.speed = 8.0f;
picked.PickedUp(gameObject);
//Destroy(gameObject);
}
}
}
In void PickedUp the Object is supposed to be destroyed and spawned again after some time(havent done it yet because destroying doesnt work).
There are no compiling error but nothing happens if i hit the object.
I tried destroying the object in script B and then it works, but if i do it that way the spawn point never gets resettet… Any ideas…
The orignal code is from an tutorial which was orignally written in JS, where everything worked…
thanks and greetings
edited for more clarity. i though maybe you need the whole code… sorry