- Home /
GameObject.Destroy(gameObject) does not destroy capsules
In this script when player and capsule or cubes touches they gotta be destroyed. code destroys cubes but it doesn't work for capsules, any idea?
public void HandleAdResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
Time.timeScale = 1f;
GameObject.Destroy(gameObject);
break;
I have this method for advertisement
public void Watchit() {
UnityEngine.Advertisements.Advertisement.Show("rewardedVideo", new ShowOptions() { resultCallback = HandleAdResult });
}
and i call it from another script attached to a button like this (Carpisma is the script for codes above)
public GameObject ui;
public void watchit() {
Carpisma usit = FindObjectOfType<Carpisma>();
usit.Watchit();
ui.SetActive(!ui.activeSelf);
}
the cubes and the capsules have that script attached to it? can you debug.log anything inside for making sure is even getting called that method when using the capsules?
Answer by panim0_unity · Feb 25, 2019 at 09:58 AM
now it doesn't destroy anything lol, i changed nothing but i don't know , this is my last thing to do , my game is ready to publish after i figure out this one please somebody help me
hello, i asked you in the comments. that script is atached to the capsules abd the cubes? can you debug.log anything inside for making sure is even getting called that method when using the capsules?
I didn't see that sorry and yes i used debug.log in case finished it really calls that but it doesn't destroy cube or capsule
but the script is in the cube and capsule you want to destroy?
Answer by LazyKnight · Feb 27, 2019 at 02:29 PM
Maybe you could try to deactivate this gameObject and move it to a "trash container" gameObject, then write a script to destroy the trash container gameObject, this should destroy its children.
I don't know the exact problem but this is an alternative way that I could suggest.
Your answer
Follow this Question
Related Questions
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
Destroy a Gameobject with a UI Button 3 Answers
Unity ads , can't we show video by clicking a button? 1 Answer
multiple objects with same script, how to destroy one of them ? 0 Answers
multiple objects with same script, how to destroy one of them ? 1 Answer