Question about deleting an object


I’m working with a team on a school project and we’re making a little race game. Sadly we are stuck on a bug/problem we are having. I hoped someone would help us here. We would really appreciate it!
So the problem we are having is that we want to delete a road after some time, but it only does it correct at the beginning and after that it is doing something I don’t really understand. We want to delete the road after 2 seconds not less (For now).
This is our code: (Sorry that the comments are in dutch)

In the code you only have to look at road and spawner (I think).

Thank you if you want to help so we can be pushed in the right direction! :slight_smile:

I’m not sure it will solve your problem but
make sure that variable taht hold millis are of type unsigned long
not int
unsigned long timer;
instead of
int timer;

Why do you have timermilliSec = 0; inside render()? Shouldn’t you update timermilliSec with millis() inside render() or inside update()? What is the purpose of this variable?

timermilliSec = millis();