commit 09155642463d9f4de800a77b3928ba1363b96125 Author: dedal.qq Date: Tue Nov 21 00:20:38 2023 +0300 first commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4709183 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Godot 4+ specific ignores +.godot/ diff --git a/animations.res b/animations.res new file mode 100644 index 0000000..fe0b0c1 Binary files /dev/null and b/animations.res differ diff --git a/character.gd b/character.gd new file mode 100644 index 0000000..a9a878a --- /dev/null +++ b/character.gd @@ -0,0 +1,53 @@ +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") + +@onready var cam_pointer = $camPointer +@onready var player = $Player + +func _ready(): + Input.mouse_mode = Input.MOUSE_MODE_CAPTURED + player.animation("idle") + +func _physics_process(delta: float): + # 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 + + # 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("ui_left", "ui_right", "ui_up", "ui_down") + # + #input_dir = cam_pointer + + var direction := Vector3(0, 0, cam_pointer.rotation.y).normalized() + print(direction) + + if Input.is_action_pressed("ui_up"): + direction = (transform.basis * direction) + else: + direction *= 0 + + if direction: + player.animation("walk") + velocity.x = direction.x * SPEED + velocity.z = direction.z * SPEED + else: + player.animation("idle") + velocity.x = move_toward(velocity.x, 0, SPEED) + velocity.z = move_toward(velocity.z, 0, SPEED) + + move_and_slide() + +func _input(event): + if event is InputEventMouseMotion: + cam_pointer.rotation.y -= event.relative.x * .01 + cam_pointer.rotation.x -= event.relative.y * .01 diff --git a/character.tscn b/character.tscn new file mode 100644 index 0000000..e4b3411 --- /dev/null +++ b/character.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=4 format=3 uid="uid://ctdna511sp1wv"] + +[ext_resource type="Script" path="res://character.gd" id="1_ex0f5"] +[ext_resource type="PackedScene" uid="uid://ckpxaevgyhrxv" path="res://persone.tscn" id="1_h0ic1"] + +[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_rjvcb"] +radius = 0.254269 +height = 2.0442 + +[node name="CharacterBody3D" type="CharacterBody3D"] +script = ExtResource("1_ex0f5") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.02691, 0) +shape = SubResource("CapsuleShape3D_rjvcb") + +[node name="Player" parent="." instance=ExtResource("1_h0ic1")] +transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0) diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..b370ceb --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/persone.gd b/persone.gd new file mode 100644 index 0000000..d09f61e --- /dev/null +++ b/persone.gd @@ -0,0 +1,15 @@ +extends Node3D + +@onready var animation_player = $AnimationPlayer + +# 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): + pass + +func animation(animation: String): + animation_player.play(animation) diff --git a/persone.tscn b/persone.tscn new file mode 100644 index 0000000..659e95c --- /dev/null +++ b/persone.tscn @@ -0,0 +1,92 @@ +[gd_scene load_steps=4 format=3 uid="uid://ckpxaevgyhrxv"] + +[ext_resource type="PackedScene" uid="uid://d1rg4jdtlq3kw" path="res://tmp/untitled.glb" id="1_dx5br"] +[ext_resource type="AnimationLibrary" uid="uid://bqlfmunuwpb7v" path="res://animations.res" id="2_11v16"] +[ext_resource type="Script" path="res://persone.gd" id="2_ioej0"] + +[node name="Persone" instance=ExtResource("1_dx5br")] +script = ExtResource("2_ioej0") + +[node name="Skeleton3D" parent="Armature" index="0"] +bones/0/position = Vector3(0.478255, 2.22684, -112.94) +bones/0/rotation = Quaternion(-0.727834, -0.0534171, 0.0123833, 0.683558) +bones/1/rotation = Quaternion(0.0262816, 0.0126933, 0.0220269, 0.999331) +bones/2/rotation = Quaternion(-0.0181982, 0.00236077, 0.0136448, 0.999739) +bones/3/rotation = Quaternion(0.0409747, 0.00259632, 0.013695, 0.999063) +bones/4/rotation = Quaternion(0.0490759, -0.000882978, 0.00392923, 0.998787) +bones/5/rotation = Quaternion(-0.0659584, 0.0119327, -0.00149326, 0.99775) +bones/9/rotation = Quaternion(-0.691383, -0.313604, 0.503434, -0.412549) +bones/10/position = Vector3(6.30416e-07, 12.2475, 6.70244e-06) +bones/10/rotation = Quaternion(0.458139, 0.142922, 0.106794, 0.870791) +bones/11/rotation = Quaternion(-2.30993e-08, -6.95112e-08, 0.0214603, 0.99977) +bones/12/position = Vector3(-1.4898e-06, 29.665, -6.49481e-07) +bones/12/rotation = Quaternion(0.0488526, -0.284795, 0.0268314, 0.956967) +bones/13/rotation = Quaternion(0.178977, 0.0734546, 0.234687, 0.952625) +bones/14/position = Vector3(-4.41073e-06, 2.33945, -2.13086e-06) +bones/14/rotation = Quaternion(-0.0712655, 0.0865974, -0.270457, 0.956177) +bones/15/position = Vector3(1.16347e-05, 1.5944, -5.10764e-05) +bones/15/rotation = Quaternion(-0.122976, -0.0755407, -0.0100728, 0.989479) +bones/17/position = Vector3(-2.88183, 13.2426, 0.307534) +bones/17/rotation = Quaternion(0.0662224, 0.000732335, 0.00842334, 0.997769) +bones/18/rotation = Quaternion(0.150976, -4.47092e-07, -0.0154755, 0.988416) +bones/19/rotation = Quaternion(0.0700831, 1.34456e-06, -0.00716218, 0.997515) +bones/20/position = Vector3(6.32101e-07, 1.63308, 4.48318e-06) +bones/21/position = Vector3(-0.0251561, 13.0978, -0.000340285) +bones/21/rotation = Quaternion(0.136517, -0.00383623, -0.0229505, 0.990364) +bones/22/rotation = Quaternion(0.151274, 1.19729e-06, -0.0154943, 0.98837) +bones/23/rotation = Quaternion(0.159918, -3.23641e-06, -0.0164103, 0.986994) +bones/25/position = Vector3(2.72726, 12.2164, 0.0574173) +bones/25/rotation = Quaternion(0.18325, -0.00466105, -0.0314975, 0.982551) +bones/26/position = Vector3(4.91753e-07, 2.16634, -1.50863e-06) +bones/26/rotation = Quaternion(0.181404, 1.90443e-05, -0.0184888, 0.983235) +bones/27/position = Vector3(-2.63634e-07, 1.87615, 5.45188e-06) +bones/27/rotation = Quaternion(0.155204, -9.37625e-06, -0.0159627, 0.987754) +bones/29/position = Vector3(5.01018, 10.9122, 0.269275) +bones/29/rotation = Quaternion(0.23387, -0.00350691, -0.0490151, 0.971025) +bones/30/rotation = Quaternion(0.151265, 4.18631e-06, -0.0154769, 0.988372) +bones/31/rotation = Quaternion(0.143481, -5.32969e-06, -0.0147375, 0.989543) +bones/32/position = Vector3(-6.56201e-07, 1.73622, 9.50202e-06) +bones/33/rotation = Quaternion(0.690834, -0.311253, 0.521999, 0.391647) +bones/34/position = Vector3(-1.09525e-06, 12.2476, 1.40246e-05) +bones/34/rotation = Quaternion(0.385103, -0.232046, -0.123851, 0.884597) +bones/35/position = Vector3(-9.56435e-07, 29.2405, 2.46052e-06) +bones/35/rotation = Quaternion(-4.03645e-07, -5.02611e-09, -0.0670901, 0.997747) +bones/36/position = Vector3(-9.0388e-07, 29.6649, -1.06813e-06) +bones/36/rotation = Quaternion(0.0593634, 0.175025, -0.00596834, 0.982755) +bones/37/rotation = Quaternion(0.181271, -0.064133, -0.25265, 0.948259) +bones/38/position = Vector3(-1.11464e-05, 2.33978, -4.94014e-05) +bones/38/rotation = Quaternion(-0.0645387, -0.0761228, 0.305739, 0.946871) +bones/39/position = Vector3(3.57463e-06, 1.59438, 1.96186e-05) +bones/39/rotation = Quaternion(-0.156488, 0.0746766, 0.0165854, 0.984713) +bones/41/rotation = Quaternion(0.0595122, -0.000990935, -0.0109698, 0.998167) +bones/42/rotation = Quaternion(0.151288, 6.61394e-07, 0.0123246, 0.988413) +bones/43/rotation = Quaternion(0.0702118, -1.63098e-06, 0.00569652, 0.997516) +bones/45/rotation = Quaternion(0.130515, 0.00368985, 0.0189178, 0.991259) +bones/46/position = Vector3(-1.3429e-06, 2.28429, -3.4464e-07) +bones/46/rotation = Quaternion(0.151542, -9.40452e-07, 0.0123364, 0.988374) +bones/47/position = Vector3(8.01394e-07, 2.38821, -1.13897e-06) +bones/47/rotation = Quaternion(0.160243, 2.71084e-06, 0.0130699, 0.986991) +bones/48/position = Vector3(-3.65433e-07, 1.75088, 5.55695e-06) +bones/49/rotation = Quaternion(0.177452, 0.0045091, 0.0264968, 0.983762) +bones/50/position = Vector3(2.30036e-06, 2.16641, 1.21775e-06) +bones/50/rotation = Quaternion(0.181732, -1.79648e-05, 0.0147027, 0.983238) +bones/51/position = Vector3(2.3276e-06, 1.8761, 9.70026e-07) +bones/51/rotation = Quaternion(0.155515, 8.43893e-06, 0.0127211, 0.987752) +bones/53/rotation = Quaternion(0.228494, 0.00340318, 0.0429769, 0.97259) +bones/54/position = Vector3(2.32442e-06, 1.56351, -1.60496e-07) +bones/54/rotation = Quaternion(0.151542, -5.41515e-07, 0.0123423, 0.988374) +bones/55/position = Vector3(-1.33549e-07, 1.27841, -3.43512e-06) +bones/55/rotation = Quaternion(0.143779, 7.78757e-07, 0.01171, 0.989541) +bones/65/rotation = Quaternion(0.13456, 0.0937333, 0.983396, -0.0777164) +bones/66/rotation = Quaternion(-0.16121, -0.0145124, 0.0378762, 0.986086) +bones/67/rotation = Quaternion(0.480945, -0.0315006, -0.0554102, 0.874431) +bones/68/rotation = Quaternion(0.347392, 7.42387e-08, 8.09045e-08, 0.93772) +bones/70/rotation = Quaternion(-0.0904756, -0.00513056, 0.995533, -0.026502) +bones/71/rotation = Quaternion(-0.0996234, 0.0839774, -0.0304167, 0.991009) +bones/72/rotation = Quaternion(0.513679, 0.0247631, 0.0210725, 0.857366) +bones/73/rotation = Quaternion(0.366584, 9.54822e-08, 4.47221e-07, 0.930385) + +[node name="AnimationPlayer" parent="." index="1"] +libraries = { +"": ExtResource("2_11v16") +} diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..35d7eaf --- /dev/null +++ b/project.godot @@ -0,0 +1,16 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="Game" +run/main_scene="res://world.tscn" +config/features=PackedStringArray("4.2", "Forward Plus") +config/icon="res://icon.svg" diff --git a/world.tscn b/world.tscn new file mode 100644 index 0000000..a75691f --- /dev/null +++ b/world.tscn @@ -0,0 +1,29 @@ +[gd_scene load_steps=3 format=3 uid="uid://d4gm4p4h8i45m"] + +[ext_resource type="PackedScene" uid="uid://ctdna511sp1wv" path="res://character.tscn" id="1_vfan6"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_c68hd"] +size = Vector3(13, 1, 17) + +[node name="Node3D" type="Node3D"] + +[node name="CharacterBody3D" parent="." instance=ExtResource("1_vfan6")] + +[node name="camPointer" type="Node3D" parent="CharacterBody3D"] +transform = Transform3D(1, 0, 0, 0, 0.999941, 0.0108383, 0, -0.0108383, 0.999941, 0, 1.6932, 0) + +[node name="Camera3D" type="Camera3D" parent="CharacterBody3D/camPointer"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.288016, 1.5802) + +[node name="StaticBody3D" type="StaticBody3D" parent="."] + +[node name="CSGBox3D" type="CSGBox3D" parent="StaticBody3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.36249, -0.54529, 3.34321) +size = Vector3(12.1666, 1, 18.2334) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, -0.526793, 2) +shape = SubResource("BoxShape3D_c68hd") + +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] +transform = Transform3D(0.870321, 0.054256, -0.489487, 0.492484, -0.0958815, 0.865024, 0, -0.993913, -0.110168, -5.29032, 3.36282, 0)