0 votes

Hello everyone, im new to programing and im struggling with my game.
I want to double the speed of an enemy, when the player is incide an area.
This is what I have.

  • gdscript
    func _on_Fov_body_entered(body: Node) -> void: velocity.x *= 2

If I do this it will keep multiplying as long as the player is incide the area.
How can i double the speed once but when i leave the area the speed(velocity.x) is back to normal.

in Engine by (18 points)

1 Answer

+1 vote
Best answer

Connect the body_exited signal and reduce the velocity in that function.

by (21,940 points)
selected by

Thank you very much that worked amazingly.

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.