Godot 4 FPS with Game Controller Support

Share any helpful tutorials or guidance related to the Godot Engine or game development.
Post Reply
aussiegamedev
Posts: 7
Joined: Wed Jul 19, 2023 1:15 am

So I thought I'd post up my FPS Controller Tutorial. I also noticed a problem with the code from the YouTube. I had forgotten to limit camera movement. So at the end of the code just add the following line...

Code: Select all

$Camera3D.rotation.x = clamp($Camera3D.rotation.x, deg_to_rad(-75), deg_to_rad(75))
The code should be like this.

Code: Select all

func apply_controller_rotation():
	if (keyb):
		var axis_vector = Vector2.ZERO
		axis_vector.x = Input.get_action_strength("look_right") - Input.get_action_strength("look_left")
		axis_vector.y = Input.get_action_strength("look_down") - Input.get_action_strength("look_up")
		axis_vector = axis_vector.normalized()
	
		if axis_vector.length():
			if InputEventJoypadMotion:
					rotate_y(deg_to_rad(-axis_vector.x) * controller_sensitivity)
					$Camera3D.rotate_x(deg_to_rad(-axis_vector.y) * controller_sensitivity)
					
	$Camera3D.rotation.x = clamp($Camera3D.rotation.x, deg_to_rad(-75), deg_to_rad(75))


Link to Tutorial....


User avatar
stayathomedev
Site Admin
Posts: 82
Joined: Mon Jul 17, 2023 2:42 pm

Thanks for sharing! What are you using for the voiceover? Had to remind myself while watching.
aussiegamedev
Posts: 7
Joined: Wed Jul 19, 2023 1:15 am

That's ok. I'll eventually link the rest. I also have a few more to do, including a settings menu with save and autoload on game start.


For the voice over, I'm using ClipChamp which is free on Windows but only 1080p and also in Microsoft 365 as a paid version which does upto 4k.
Attalfvot
Posts: 11
Joined: Thu Nov 07, 2024 3:04 pm

Eshelman School of Pharmacy, University of North Carolina, Chapel Hill J <a href=https://fastpriligy.top/>where to buy priligy in malaysia</a>
Post Reply