Prefabs wont disapear

i tried a doodlejump clone but the items that are beneath the player dont get destroyed
i tried something like that on the itemprefab:

public gameObject Character;
void Update()
    if (Character.transform.position.y -15f> transform.position.y)

but it does not work…


I don’t mean to point out the obvious but is the difference greater than 15?
But one thing I notice that is wrong with your script is public gameObject Character should be public GameObject Character. Note the uppercase G

Thanks for your answer. Yes difference is greater than 15 and in my script GameObject Character has uppercase G

Greetings Marcurion

Just using the code you gave in your question I have an object destroying when it is 15 below whatever target I give it. The problem does not appear to be in your script as it functions fine, perhaps you are linking your objects to the wrong “character” object, or they never actually get 15 below the player to be destroyed. If your objects are prefabs that are being instantiated be sure to check that they are properly linking to the character.

Try changing the distance at which they destroy to a very small number for testing purposes, whatever the problem is it is not with your script. as long as gameObject is an uppercase G that is.

No sorry, i would be happy if that were the problem - all prefabs are properly linked.
Maybe it matters that i let the prefabs spawn by another prefab…

MFG Marcurion

Ok i found something: The problem occurs if i put the box with the script attached into the empty prefab,
the link to the character gets cut, and it refuses drag and drop a new GameObject, but i can select an GameObject over the small circle menue, however the script does not work once it is in the prefab

Greetings Marcurion