Input doesn't work in integrated forces

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By hard

Not Works

func _integrate_forces(state):
if Input.is_action_pressed("ui_up"):
	print("Working")
pass

But it Works in

func _physics_process(delta):
if Input.is_action_pressed("ui_up"):
	print("Working")
pass

Have you tried just having the print function and no input first? What kind of node is it attached too? Integrate forces exist only for nodes extending rigid physics bodies. And its purpose is only for adding forces to the body.

Gluon | 2021-12-29 19:18

Also this process wont be called if a rigid body goes to sleep you will need to keep the body awake by creating a collision, applying a force to it, or by disabling the can_sleep property.

Gluon | 2021-12-29 19:26

:bust_in_silhouette: Reply From: Gluon

Well as you seem to have ignored my comments with questions in I will simply add it here. You wont get an answer as you havent included any information here to allow anyone to determine what is going wrong but it is likely one of the below;

  1. The function is being called but the action button isnt being pressed when it is called
    Test: Remove the if function and just have a print to check

  2. The function is not on the correct node type
    Test: Try adding it to a rigidbody node

  3. The node is asleep when the call should happen
    Test: Disable the can_sleep property.

Thanks your third solution is working

hard | 2022-01-01 10:35