How to keep checking when player stands on something special (like fire for example)?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Qws

When collision is detected, it triggers a signal one time through “area_enters”.

But how to keep checking if a character lets say stands on fire ground.

I want something like this:

func _fixed_process(delta):

What’s best realistic code to make this possible in Godot? Which class, api do I need?


SingingApple | 2018-02-21 16:19

:bust_in_silhouette: Reply From: SingingApple

Judging by what I understand of your question this is pretty easy, you can create a variable called ‘on_fire_ground’ and set it to false.
And for you information, there is another signal called ‘area_exit’. You can take advantage of this and on the ‘on_area_enter’ function you can set ‘on_fire_ground’ to true and set it to false in the ‘on_area_exit’ function.

Hope this helps.

:bust_in_silhouette: Reply From: gtkampos

You can create a timer that will start on area_enter signal. So, in timeout signal you do damage to the player. Then check area_exit signal and stop the timer.

What a coincidence! I had written a similar answer in the past to another question: how to make area2d keep scanning for collision - Archive - Godot Forum

SingingApple | 2018-02-21 16:15