+1 vote

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 Yellow
Lazer = 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 !Has
beenTriped:
$Sprite.texture = Yellow
Lazer
Triped = false
$Timer.start(0.05)
HasbeenTriped = true
if Triped and HasbeenTriped:
$Sprite.texture = RedLazer
emit
signal("Openspike")
Lazer
detected = 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 = Green
Lazer

Godot version v3.2.2
in Engine by (20 points)

1 Answer

0 votes

if I'm not wrong you should be able to call stop() on any timer,
in your case you could try $Timer.stop()

by (34 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.