Skip to content

Instantly share code, notes, and snippets.

View bramreth's full-sized avatar

Bram bramreth

View GitHub Profile
@bramreth
bramreth / NavigationNPC.gd
Created February 17, 2024 11:59
Godot 4 Navigation Tutorial Script
extends CharacterBody3D
@onready var navigation_agent_3d: NavigationAgent3D = $NavigationAgent3D
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("ui_accept"):
var random_position := Vector3.ZERO
random_position.x = randf_range(-5.0, 5.0)
random_position.z = randf_range(-5.0, 5.0)
navigation_agent_3d.set_target_position(random_position)
@bramreth
bramreth / Player.gd
Created July 24, 2023 23:52
How to make a 3D Platfomer in Godot 4: Setup, Movement, and Camera Controls - code dump
extends RigidBody3D
var mouse_sensitivity := 0.001
var twist_input := 0.0
var pitch_input := 0.0
@onready var twist_pivot := $TwistPivot
@onready var pitch_pivot := $TwistPivot/PitchPivot
func _ready() -> void:
@bramreth
bramreth / Godot4FPS.gd
Last active April 12, 2024 22:59
The code for a first person movement youtube tutorial in Godot 4
extends CharacterBody3D
const SPEED = 5.0
const JUMP_VELOCITY = 4.5
# Get the gravity from the project settings to be synced with RigidDynamicBody nodes.
var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity")
@onready var neck := $Neck
@onready var camera := $Neck/Camera3d