parent
421a90ec17
commit
4ce0367f15
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,37 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://dbd1niu3tp8y5"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cvn2p215jq2am" path="res://graphics/testingground/concerned.png" id="1_5jpx2"]
|
||||
[ext_resource type="Script" path="res://scripts/player_3d.gd" id="1_08wm4"]
|
||||
[ext_resource type="Script" path="res://scripts/camera_pivot.gd" id="3_drcdp"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_1vdrh"]
|
||||
radius = 0.0478421
|
||||
height = 0.234557
|
||||
|
||||
[node name="Player3d" type="Node3D"]
|
||||
|
||||
[node name="CharacterBody3D" type="CharacterBody3D" parent="."]
|
||||
script = ExtResource("1_08wm4")
|
||||
SPEED = 0.5
|
||||
|
||||
[node name="Sprite" type="Sprite3D" parent="CharacterBody3D"]
|
||||
transform = Transform3D(0.04, 0, 0, 0, 0.04, 0, 0, 0, 0.04, 0, 0.110813, 0)
|
||||
billboard = 1
|
||||
shaded = true
|
||||
texture = ExtResource("1_5jpx2")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="CharacterBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.119886, 0)
|
||||
shape = SubResource("CapsuleShape3D_1vdrh")
|
||||
|
||||
[node name="CameraPivot" type="Node3D" parent="CharacterBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.159723, 0)
|
||||
script = ExtResource("3_drcdp")
|
||||
canPitch = true
|
||||
canYaw = true
|
||||
|
||||
[node name="SubPivot" type="Node3D" parent="CharacterBody3D/CameraPivot"]
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="CharacterBody3D/CameraPivot/SubPivot"]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.871025, 0.491238, 0, -0.491238, 0.871025, 0, 0.658355, 1.24487)
|
||||
fov = 28.5
|
||||
@ -0,0 +1,22 @@
|
||||
extends Node3D
|
||||
|
||||
@export var canPitch: bool = false
|
||||
@export var canYaw: bool = false
|
||||
@export var rotateSpeed: float = 0.003
|
||||
@onready var sub_pivot: Node3D = $SubPivot
|
||||
|
||||
func _ready() -> void:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("click"):
|
||||
if Input.mouse_mode == Input.MOUSE_MODE_VISIBLE:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
if event is InputEventMouseMotion:
|
||||
if Input.mouse_mode != Input.MOUSE_MODE_CAPTURED: return
|
||||
if canYaw: sub_pivot.rotate_x(event.relative.y * -rotateSpeed)
|
||||
if canPitch: rotate_y(event.relative.x * -rotateSpeed)
|
||||
@ -0,0 +1,30 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
|
||||
@export var SPEED = 1.0
|
||||
|
||||
@onready var camera_3d: Camera3D = $CameraPivot/SubPivot/Camera3D
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
# Add the gravity.
|
||||
if not is_on_floor():
|
||||
velocity += get_gravity() * delta
|
||||
|
||||
# Handle jump.
|
||||
#if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||
# velocity.y = JUMP_VELOCITY
|
||||
|
||||
# Get the input direction and handle the movement/deceleration.
|
||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||
var input_dir := Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||
input_dir = input_dir.rotated(-camera_3d.global_rotation.y)
|
||||
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
if direction:
|
||||
velocity.x = direction.x * SPEED
|
||||
velocity.z = direction.z * SPEED
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
velocity.z = move_toward(velocity.z, 0, SPEED)
|
||||
|
||||
move_and_slide()
|
||||
Loading…
Reference in new issue