Skip to content

Instantly share code, notes, and snippets.

View bramreth's full-sized avatar

Bram bramreth

View GitHub Profile
@bramreth
bramreth / projectile.gd
Created July 21, 2024 20:50
Source code for my RayCast3D Godot 4.2.2 Projectiles tutorial
extends RayCast3D
@export var speed := 50.0
@onready var remote_transform = RemoteTransform3D.new()
func _physics_process(delta: float) -> void:
position += global_basis * Vector3.FORWARD * delta * speed
target_position = Vector3.FORWARD * delta * speed
force_raycast_update()
@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 July 12, 2024 09:22
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