Upload files to "/"

This commit is contained in:
karlji 2024-08-13 14:34:56 +00:00
commit 4777081ad9
4 changed files with 237 additions and 0 deletions

28
Camera3D.gd Normal file
View File

@ -0,0 +1,28 @@
extends Camera3D
@export var pivot: Node
@export var camera_top: Node
const MIN_ZOOM = 5.0
const MAX_ZOOM = 30.0
const FOV_MULTIPLIER = 0.1
var desiredDistance = 5.0
var distanceStep = 1.0
var desiredFov = 85.0
var fovStep = 1.0
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
#temp - camera for development
if Input.is_action_pressed("camera"):
camera_top.current = true
else:
self.current = true
pass

36
main.tscn Normal file
View File

@ -0,0 +1,36 @@
[gd_scene load_steps=6 format=3 uid="uid://capk710xx63l8"]
[ext_resource type="Material" uid="uid://cwg48c2qqksp5" path="res://Art/ground.tres" id="1_gkoa0"]
[ext_resource type="PackedScene" uid="uid://d33hla52f5lvv" path="res://Scenes/player.tscn" id="2_ethmb"]
[sub_resource type="BoxShape3D" id="BoxShape3D_2dbh0"]
size = Vector3(100, 1, 100)
[sub_resource type="BoxMesh" id="BoxMesh_svgqi"]
material = ExtResource("1_gkoa0")
size = Vector3(100, 1, 100)
[sub_resource type="CapsuleMesh" id="CapsuleMesh_k7wta"]
[node name="Main" type="Node"]
[node name="Ground" type="StaticBody3D" parent="."]
[node name="CollisionShape3D" type="CollisionShape3D" parent="Ground"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0)
shape = SubResource("BoxShape3D_2dbh0")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Ground"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0)
mesh = SubResource("BoxMesh_svgqi")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.372696, 0.927953, 0, -0.927953, 0.372696, 0, 33.3412, 6.74177)
shadow_enabled = true
[node name="Player" parent="." instance=ExtResource("2_ethmb")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.177785, 0)
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.55861, 1.07345, 0)
mesh = SubResource("CapsuleMesh_k7wta")

60
player.gd Normal file
View File

@ -0,0 +1,60 @@
extends CharacterBody3D
const SPEED = 5.0
const JUMP_VELOCITY = 4.5
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
var mouse_origin
@export var sensitivity = 200
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
var direction = Vector3.ZERO
var modifier = 1
# We check for each move input and update the direction accordingly.
if Input.is_action_pressed("move_right"):
rotation.y -= 0.04
if Input.is_action_pressed("move_left"):
rotation.y += 0.04
if Input.is_action_pressed("move_back"):
direction += transform.basis.z
modifier = 0.5
$"Pivot/Root Scene/AnimationPlayer".play("CharacterArmature|Run_Back")
if Input.is_action_pressed("move_forward"):
direction -= transform.basis.z
$"Pivot/Root Scene/AnimationPlayer".play("CharacterArmature|Run")
if direction != Vector3.ZERO && is_on_floor():
direction = direction.normalized()
velocity.x = direction.x * SPEED * modifier
velocity.z = direction.z * SPEED * modifier
elif is_on_floor():
$"Pivot/Root Scene/AnimationPlayer".play("CharacterArmature|Idle")
velocity.x = 0
velocity.z = 0
move_and_slide()
func _input(event):
# Changing mouse to Warp Mode on right mouse
if event is InputEventMouseButton && event.button_index == 2:
if event.pressed == true:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
mouse_origin = event.position
if event.pressed == false:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
# Handling rotation on mouse movement
if Input.is_action_pressed("right_click"):
if event is InputEventMouseMotion:
rotation.y -= event.relative.x / sensitivity
$CameraPivot.rotation.x -= event.relative.y / sensitivity
$CameraPivot.rotation.x = clamp($CameraPivot.rotation.x, deg_to_rad(-45), deg_to_rad(90))

113
player.tscn Normal file
View File

@ -0,0 +1,113 @@
[gd_scene load_steps=5 format=3 uid="uid://d33hla52f5lvv"]
[ext_resource type="Script" path="res://Scenes/player.gd" id="1_4kub8"]
[ext_resource type="PackedScene" uid="uid://r6eytm271sqt" path="res://Art/Adventurer.glb" id="1_f6620"]
[ext_resource type="Script" path="res://Scenes/Camera3D.gd" id="3_pm6qi"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_xj4i6"]
radius = 0.362804
height = 1.84524
[node name="Player" type="CharacterBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.08211, 0)
script = ExtResource("1_4kub8")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.911459, 0)
shape = SubResource("CapsuleShape3D_xj4i6")
[node name="Pivot" type="Node3D" parent="."]
[node name="Root Scene" parent="Pivot" instance=ExtResource("1_f6620")]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
[node name="Skeleton3D" parent="Pivot/Root Scene/RootNode/CharacterArmature" index="0"]
bones/0/rotation = Quaternion(0.707107, 8.42937e-08, 8.42937e-08, 0.707107)
bones/1/position = Vector3(4.53219e-06, 0.00828953, -0.000456057)
bones/1/rotation = Quaternion(-9.79661e-32, 0.23553, 4.0424e-31, 0.971867)
bones/2/rotation = Quaternion(-0.0694294, -2.6887e-07, -3.13691e-08, 0.997587)
bones/4/rotation = Quaternion(0.0854647, -0.237483, 0.0115782, 0.967555)
bones/4/scale = Vector3(1, 1, 1)
bones/5/rotation = Quaternion(0.00363648, 2.25668e-10, -2.13629e-09, 0.999993)
bones/6/rotation = Quaternion(0.0306859, 1.42484e-06, -5.16837e-09, 0.999529)
bones/7/rotation = Quaternion(-0.0245109, -0.000275392, 0.000120303, 0.9997)
bones/7/scale = Vector3(1, 1, 1)
bones/9/rotation = Quaternion(0.456199, 0.840232, 0.106907, -0.272881)
bones/9/scale = Vector3(1, 1, 1)
bones/10/rotation = Quaternion(0.674998, -0.403884, -0.387776, -0.480506)
bones/11/rotation = Quaternion(-0.121328, -0.0295654, -0.184313, 0.974902)
bones/11/scale = Vector3(1, 1, 1)
bones/12/rotation = Quaternion(0.0112397, 0.0177445, 0.0104792, 0.999725)
bones/12/scale = Vector3(1, 1, 1)
bones/13/rotation = Quaternion(-0.0088578, 0.0142183, -0.0933198, 0.995495)
bones/14/rotation = Quaternion(-0.0408909, -0.0321456, 0.0670435, 0.996393)
bones/14/scale = Vector3(1, 1, 1)
bones/15/rotation = Quaternion(-0.0790735, 0.0116557, 0.0250531, 0.996486)
bones/16/rotation = Quaternion(-0.0298723, 0.00978076, 0.00496208, 0.999494)
bones/16/scale = Vector3(1, 1, 1)
bones/18/rotation = Quaternion(0.0257227, -0.0194088, 0.0169106, 0.999338)
bones/18/scale = Vector3(1, 1, 1)
bones/19/rotation = Quaternion(-0.0899747, 0.0254326, -0.00615306, 0.9956)
bones/19/scale = Vector3(1, 1, 1)
bones/23/rotation = Quaternion(0.00911317, -0.0503409, 0.127957, 0.990459)
bones/23/scale = Vector3(1, 1, 1)
bones/25/scale = Vector3(1, 1, 1)
bones/26/rotation = Quaternion(-0.0751798, 0.0300851, -0.00748025, 0.996688)
bones/28/rotation = Quaternion(0.0170326, -0.07192, 0.226359, 0.971236)
bones/30/scale = Vector3(1, 1, 1)
bones/33/rotation = Quaternion(0.00387702, 0.198608, -0.345762, 0.917054)
bones/33/scale = Vector3(1, 1, 1)
bones/34/rotation = Quaternion(0.0417278, -0.122015, 0.0851815, 0.987985)
bones/34/scale = Vector3(1, 1, 1)
bones/35/rotation = Quaternion(-0.0885877, -0.0556028, 0.121992, 0.987005)
bones/35/scale = Vector3(1, 1, 1)
bones/38/rotation = Quaternion(-0.626873, -0.307534, -0.439377, 0.565156)
bones/39/rotation = Quaternion(-0.205763, -0.193786, 0.323958, 0.902862)
bones/40/rotation = Quaternion(0.0105415, -0.0212143, -0.0393221, 0.998946)
bones/40/scale = Vector3(1, 1, 1)
bones/41/rotation = Quaternion(-0.00885779, -0.0142183, 0.0933198, 0.995495)
bones/42/rotation = Quaternion(-0.0528572, 0.0336407, -0.0664886, 0.995818)
bones/42/scale = Vector3(1, 1, 1)
bones/43/rotation = Quaternion(-0.0887832, -0.0113618, -0.0247415, 0.995679)
bones/44/rotation = Quaternion(-0.0298723, -0.00978076, -0.00496206, 0.999494)
bones/44/scale = Vector3(1, 1, 1)
bones/46/scale = Vector3(1, 1, 1)
bones/47/rotation = Quaternion(-0.104393, -0.0269019, -0.0690116, 0.991774)
bones/51/rotation = Quaternion(0.00911316, 0.0503409, -0.127957, 0.990459)
bones/51/scale = Vector3(1, 1, 1)
bones/52/rotation = Quaternion(-0.0819329, -0.160517, 0.0365542, 0.982947)
bones/52/scale = Vector3(1, 1, 1)
bones/53/scale = Vector3(1, 1, 1)
bones/54/rotation = Quaternion(-0.0751798, -0.0300851, 0.00748026, 0.996688)
bones/56/rotation = Quaternion(0.0170325, 0.07192, -0.226359, 0.971236)
bones/57/rotation = Quaternion(-0.126589, -0.179584, 0.161972, 0.962024)
bones/58/scale = Vector3(1, 1, 1)
bones/61/rotation = Quaternion(0.0195577, -0.185723, 0.435159, 0.880773)
bones/61/scale = Vector3(1, 1, 1)
bones/62/rotation = Quaternion(0.0417277, 0.122015, -0.0851815, 0.987986)
bones/63/rotation = Quaternion(-0.0885878, 0.0556028, -0.121992, 0.987005)
bones/63/scale = Vector3(1, 1, 1)
bones/65/rotation = Quaternion(-0.535617, 0.0211013, 0.835658, -0.119768)
bones/65/scale = Vector3(1, 1, 0.999973)
bones/66/rotation = Quaternion(0.186823, 0.68198, -0.186822, 0.681981)
bones/68/rotation = Quaternion(0.55499, 0.125435, 0.804817, 0.168885)
bones/68/scale = Vector3(1, 1, 0.999973)
bones/69/rotation = Quaternion(0.167543, -0.686971, 0.167542, 0.686972)
bones/71/rotation = Quaternion(0.614414, 0.348044, -0.346153, 0.617689)
bones/71/scale = Vector3(1, 1, 1)
bones/77/rotation = Quaternion(-0.00267377, -3.40937e-05, 9.11591e-08, 0.999996)
[node name="CameraPivot" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.887462, 0.460881, 0, -0.460881, 0.887462, 0, 1.89226, 1.01148)
[node name="Camera3D" type="Camera3D" parent="CameraPivot" node_paths=PackedStringArray("pivot", "camera_top")]
fov = 85.0
script = ExtResource("3_pm6qi")
pivot = NodePath("..")
camera_top = NodePath("../../CameraTop")
[node name="CameraTop" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.572003, 0.820252, 0, -0.820252, 0.572003, 0, 3.46245, 1.18061)
fov = 85.0
[editable path="Pivot/Root Scene"]