0 votes

I made a hitscan weapon, using RayCast. When the player presses the left mouse button, the RayCast checks if an enemy is in it's way. I want this check to last longer because it only lasts for one very short moment (good for a pistol). I want this check to last longer, so it stays after the click for a few miliseconds more (for a burst rifle).

Godot version v3.3.2
in Engine by (46 points)

1 Answer

+1 vote
Best answer

RayCast (if you're about a node) "lasts" as long as its enabled property is true.
I haven't seen your code, but seems like you're turning it off, right after mouse event is processed.

If so, you need a one-shot Timer to turn it off: Mose event makes both RayCast.enabled = true and Timer.start(), but RayCast.enabled = false should be executed only from Timer's signal (timeout).

by (1,646 points)
selected by
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 Frequently asked questions and 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 [email protected] with your username.