0 votes

Hello.
My idea for my game is that the player can switch to different modes and I am planning to have different sprites for the player to switch to. I tried doing Input.isactionpressed to switch to a different sprite texture and when I press that button again it returns it back to the previous texture. The problem I am having is that when I press it, the texture switches back and forth too fast. I think the problem is because the inputs are under the physicsprocess(delta) function. Is there any way for me to switch to a different texture once?

Sorry if my question is already answered or it seems stupid. I couldn't find an answer on google and I am pretty new to game development. Thanks.

in Engine by (26 points)

1 Answer

+1 vote
Best answer

The function isn't the problem,

Input.is_action_pressed 

will return true while a key is pressed.
You're looking for

Input.is_action_just_pressed

which will return true for only a single frame.

by (3,257 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.