0 votes

Im making the FPS rotation control for the gamepad

    rotation.x = Input.is_action_just_pressed("turn_left") - Input.is_action_just_pressed("turn_right")
    rotation.y = Input.is_action_just_pressed("look_up") - Input.is_action_just_pressed("look_down")

I keep getting this error
Parse Error: Invalid operand types ("bool" and "bool") to operator "-".

Godot version 3.4
in Engine by (55 points)

1 Answer

0 votes

You're getting the error because is_action_just_pressed() returns a bool (so, true or false). And, since it's not possible to subtract one bool from another, you get the error you mentioned. Maybe you're looking for something like:

rotation.x = Input.get_action_strength("turn_left") - Input.get_action_strength("turn_right")

... or ...

rotation.x = get_axis("turn_left", "turn_right")
by (19,302 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 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.