camera control with controller

Godot Version

4.1

Question

I am making a 3rd person game and My camera works when I use mouse but it only works each time I change the amount my controller is held

	elif event is InputEventJoypadMotion:
		if event.axis == 2:
			rot_x += event.axis_value * LOOKAROUND_SPEED * 10
			_keep_moving()
			
func _keep_moving():
	transform.basis = Basis() # reset rotation
	rotate_object_local(Vector3(0, 1, 0), rot_x) # first rotate in Y
	timer.start()
	print("timer start")


func _on_timer_timeout():
	print("timer end")
	if rot_x != 0:
		_keep_moving()
		
 

this is my code for the controller there is an if before the elif btw.

Don’t use the event handler because it will fire only when a change happens, as you already concluded. Instead, query the state of the axis each frame using the Input singleton.

2 Likes

When making a look feature for both mouse and controller, you have to reset the value every frame for the mouse and not reset it for the controller.

For an example, take a look at my Controller plugin and 3D Camera plugin.

I will look into that thank you

1 Like