Hello. Im very new to programing so still have a lot to learn. But have been learning through reading the documentation, youtube tutorials and these forums.
I have a simple game where stuff f.e. cubes randomly spawn and go twards the player. So I wanted to make a simple script to make the cubes despawn when they go behind the player (player position is Z = -100).
My Script:
public class destroyUnderZvalue : MonoBehaviour
{
public float destroyPosition = -105.0f;
void update()
{
if (transform.position.z <= destroyPosition)
{
Destroy (gameObject);
}
}
}
Tho I dont know it its <= or >= since the value is lower (-105 is lower than -100)
But when I attatch it to the cubes it does nothing. Thank you in Advance.