Topic was automatically imported from the old Question2Answer platform.
Asked By
Blueberry
Hi,
Currently, I’m trying to implement a day and night cycle.
For that I implemented a texture progress with a black texture that rises from the bottom of the screen value(0) to the top of the screen (value 100)
My character is standing at value 70 (but this can change, if he moves).
![Concept]
I want to print to console if the black texture overlaps the character. Therefore I was using the bodyEntered signal of my Area2D (which is parent of the texture progress) but this doesn’t work.
How to do that, or maybe is there a better way to achieve the same result?
Only certain nodes would count as a “body” like a kinematicbody2d for instance. I dont think a texture would count as such.
I think the easiest way would be to have a parent node check the position of your night texture directly and work on the assumption that when your “night” texture is above a certain level and your character is at a certain level that they will then be intersecting. So for example you could have something like
if $Player.global_position.y > $Night.global_position.y - 30:
your code here
Obviously you would need to play around with the final figure to work out what works best given the size of your night texture as the global position will be the center of that texture but this should work.
Okay changed to a “normal” texture which now has a width of 5000px to fit the whole screen.
I’m still struggeling with what to do after the overlap.
Ideally the y-value of the texture is increase every second and after the overlap I want to reduce the player health every second by 3.
But the sleep don’t seem to work. Is the issue that it’s called in the _physics_process funcion?
Blueberry | 2023-02-14 14:06
I dont see where you are actually calling the function sleep above?
Edit oh sorry no I see it
No that should call the function if you activate the check_darkness_reaches_player function. Have you tried putting a print function in sleep to see if that is activated?
You are yielding but then not seeming to do anything in the sleep function though?