Im having problem making a first person camera (you can look around, move etc) and learning the godot languge in general because there's very few tutorials out there. I thought that maybe someone here could help me out with making it, or linking me to a tutorial.

in Engine

Last year I wrote a tutorial about FPS, that is I guess what you're looking for:
https://github.com/gokudomatic/godot/blob/master/demos/3d/kinematic_fps/documentation/Documentation.pdf

It is already an old tutorial (sorry about that but godot is always evolving). If you want, you can check the current project I'm working on, which uses my controller on a recent godot version:
https://github.com/gokudomatic/godot_fps_crawler

Note: my controller uses some concepts of already existing fps controllers, but I rewrite it from scratch with a kinematic body instead of a rigid body. My version doesn't have the problem of bouncing when going down a steep slope. And it manages moving platforms (staying on the floor when the lift goes down).

by (697 points)
selected

I didn't know this tutorial, it's so useful thanks!

You can find examples here and also here, the latter is a bit more robust (it handles jumping better). Both are based on a RigidBody character.

by (11,255 points)

Use this code and make sure you have a node called "Head" that's either a camera or a parent of a camera.

``````extends KinematicBody

var speed = 8
var ground_acceleration = 8
var air_acceleration = 2
var acceleration = ground_acceleration
var jump = 4.5
var gravity = 9.8
var stick_amount = 10
var mouse_sensitivity = 1

var direction = Vector3()
var velocity = Vector3()
var movement = Vector3()
var gravity_vec = Vector3()
var grounded = true

func _input(event):
if event is InputEventMouseMotion:
rotation_degrees.y -= event.relative.x * mouse_sensitivity / 10

direction = Vector3()
direction.z = -Input.get_action_strength("move_forward") + Input.get_action_strength("move_backward")
direction.x = -Input.get_action_strength("move_left") + Input.get_action_strength("move_right")
direction = direction.normalized().rotated(Vector3.UP, rotation.y)

func _physics_process(delta):
if is_on_floor():
gravity_vec = -get_floor_normal() * stick_amount
acceleration = ground_acceleration
grounded = true
else:
if grounded:
gravity_vec = Vector3.ZERO
grounded = false
else:
gravity_vec += Vector3.DOWN * gravity * delta
acceleration = air_acceleration

if Input.is_action_just_pressed("jump") and is_on_floor():
grounded = false
gravity_vec = Vector3.UP * jump

velocity = velocity.linear_interpolate(direction * speed, acceleration * delta)
movement.z = velocity.z + gravity_vec.z
movement.x = velocity.x + gravity_vec.x
movement.y = gravity_vec.y

move_and_slide(movement, Vector3.UP)
``````
by (14 points)