So I am trying to make a lazer that when the player walks through it it will activate something but if it dashes it will just be on the middle of activating it and will stop. So I use a Timer, which is a child of an area, 0.5 seconds to make it on the middle of activating making it color yellow and 0.5 seconds a again to make it activate making it color red but when you exit the area2d it will be color green but it will still turn red activating something I need a way to stop the timer.
If you need its code here (also its activating spikes which will insta kill you):
const GreenLazer = preload("res://Assests/Tile Set/Green Lazer.png.png")
const YellowLazer = preload("res://Assests/Tile Set/Yellow Lazer.png.png")
const Red_Lazer = preload("res://Assests/Tile Set/Red Lazer.png.png")
var Triped = false
var HasbeenTriped = false
var Lazer_detected = false
signal Open_spike
func physicsprocess(delta):
Lazer_Checking()
func LazerChecking():
if Triped and !HasbeenTriped:
$Sprite.texture = YellowLazer
Triped = false
$Timer.start(0.05)
HasbeenTriped = true
if Triped and HasbeenTriped:
$Sprite.texture = RedLazer
emitsignal("Openspike")
Lazerdetected = true
else:
$Sprite.texture = Green_Lazer
func onLazerbodyentered(body):
if "Player" in body.name:
#emitsignal("Openspike")
print("start")
$Timer.start(0.05)
func onTimer_timeout():
Triped = true
print("end")
func onLazerbodyexited(body):
if !Lazerdetected:
$Sprite.texture = GreenLazer