Setup a basic Godot First Person Controller

Pubblicato il: 26 agosto 2021
sul canale di: gamevisualz
278
11

This video will take you through the process of making a First Person Controller.


A First Person Controller is a setup that allows you to move your character representation in all directions, to look in all directions with our mouse, be able to jump as well as react to gravity.
This is the entire tutorial from start to finish.

how to set up animations for export in Blender 2.91.

how to use the proper settings to export your animations as a GLTF file to bring into Godot

how make and texture basic terrain in Godot

How to use the open source program Gimp to make very basic textures

how to set up and work with animation trees in Godot

how to write script that allows your animation to activate when you press a keyboard key

https://godotengine.org/

https://www.gimp.org/downloads/

This is the full tutorial.
Download Godot file
https://drive.google.com/file/d/1B3vR...

If you like this video please subscribe and thank you for watching.

The code from the finished tutorial can be found below.


extends KinematicBody

export var speed = 10
export var acceleration = 5
export var gravity = 0.98
export var jump_power = 30
export var mouse_sensitivity = 0.3

var velocity = Vector3()

onready var head = $Head
onready var camera = $Head/Camera

func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func _input(event):
if event is InputEventMouseMotion:
rotate_y(deg2rad(-event.relative.x * mouse_sensitivity))
head.rotate_x(deg2rad(-event.relative.y * mouse_sensitivity))
head.rotation.x = clamp(head.rotation.x, deg2rad(-89), deg2rad(89))

func _process(delta):
if Input.is_action_just_pressed("ui_cancel"):
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)



func _physics_process(delta):
var head_basis = head.get_global_transform().basis
var direction = Vector3()
if Input.is_action_pressed("move_forward"):
direction -= head_basis.z
elif Input.is_action_pressed("move_backward"):
direction += head_basis.z

if Input.is_action_pressed("move_left"):
direction -= head_basis.x
elif Input.is_action_pressed("move_right"):
direction += head_basis.x

direction = direction.normalized()

velocity = velocity.linear_interpolate(direction * speed, acceleration * delta)
velocity.y -= gravity

if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y += jump_power

velocity = move_and_slide(velocity,Vector3.UP)


In questa pagina del sito puoi guardare il video online Setup a basic Godot First Person Controller della durata di ore minuti seconda in buona qualità , che l'utente ha caricato gamevisualz 26 agosto 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 278 volte e gli è piaciuto 11 spettatori. Buona visione!