Add project files
This commit is contained in:
commit
b10fbca719
14 changed files with 588 additions and 0 deletions
42
example/SimpeFirstPersonController.gd
Normal file
42
example/SimpeFirstPersonController.gd
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
extends Camera3D
|
||||
|
||||
# Copyright (c) 2024 Julian Müller (ChaoticByte)
|
||||
|
||||
@export var movement_speed = 3.0
|
||||
@export var mouse_sensitivity = 0.01
|
||||
@export var mouse_x_min: float = -PI/2
|
||||
@export var mouse_x_max: float = PI/2
|
||||
|
||||
func _ready() -> void:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
func toggle_mouse_mode():
|
||||
if Input.mouse_mode == Input.MOUSE_MODE_VISIBLE:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
else:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
rotate_y(-event.relative.x * mouse_sensitivity)
|
||||
rotation.x = clamp(
|
||||
rotation.x - event.relative.y * mouse_sensitivity,
|
||||
mouse_x_min, mouse_x_max
|
||||
)
|
||||
elif event is InputEventKey:
|
||||
if event.is_action_released("ui_cancel"):
|
||||
toggle_mouse_mode()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
var dir = Vector3()
|
||||
if Input.is_action_pressed("forward"):
|
||||
dir.z -= 1
|
||||
if Input.is_action_pressed("backward"):
|
||||
dir.z += 1
|
||||
if Input.is_action_pressed("left"):
|
||||
dir.x -= 1
|
||||
if Input.is_action_pressed("right"):
|
||||
dir.x += 1
|
||||
position += (
|
||||
dir.normalized() * delta * movement_speed
|
||||
).rotated(Vector3.UP, rotation.y)
|
||||
11
example/example.gd
Normal file
11
example/example.gd
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
extends Node3D
|
||||
|
||||
@export var wind_strength = 0.2;
|
||||
|
||||
@onready var fps_label: Label = $UI/FPS
|
||||
|
||||
func _ready() -> void:
|
||||
Wind.wind_strength = wind_strength;
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
fps_label.text = "FPS: %d" % Engine.get_frames_per_second()
|
||||
160
example/example.tscn
Normal file
160
example/example.tscn
Normal file
File diff suppressed because one or more lines are too long
BIN
example/screenshots/example-video.mkv
Normal file
BIN
example/screenshots/example-video.mkv
Normal file
Binary file not shown.
BIN
example/screenshots/screenshot.png
Normal file
BIN
example/screenshots/screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
Reference in a new issue