From 4b4d97746c8e203a65795f3e40c434b153d1ea6b Mon Sep 17 00:00:00 2001 From: Clevertop Date: Sun, 11 Aug 2024 12:27:38 +1000 Subject: [PATCH] dash working --- Commands/command_block.gd | 1 + Commands/command_block.tscn | 3 ++- Commands/haste_new.png.import | 13 ++++++----- Commands/phase_shift_new.png.import | 13 ++++++----- Levels/StartingRoom.tscn | 34 +++++++++++++++++++++++++---- Scripts/Player.gd | 28 ++++++++++++++++++++++-- TODO.txt | 12 ++++++---- player.tscn | 6 ++++- 8 files changed, 86 insertions(+), 24 deletions(-) diff --git a/Commands/command_block.gd b/Commands/command_block.gd index 073d230..56dd240 100644 --- a/Commands/command_block.gd +++ b/Commands/command_block.gd @@ -4,6 +4,7 @@ class_name Command_Block @export var command_name : String @export var command_sprite : Texture2D#: +@export var collider : CollisionShape3D #set(new_texture): #if command_sprite != null: #command_sprite.changed.disconnect(on_texture_changed) diff --git a/Commands/command_block.tscn b/Commands/command_block.tscn index 8c210b5..d43ad40 100644 --- a/Commands/command_block.tscn +++ b/Commands/command_block.tscn @@ -10,8 +10,9 @@ size = Vector3(0.5, 0.5, 0.5) [sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_mmdx7"] points = PackedVector3Array(0.25, 0.25, 0.25, 0.25, 0.25, -0.25, -0.25, 0.25, 0.25, 0.25, -0.25, 0.25, 0.25, -0.25, -0.25, -0.25, 0.25, -0.25, -0.25, -0.25, 0.25, -0.25, -0.25, -0.25) -[node name="BaseCommand" type="RigidBody3D"] +[node name="BaseCommand" type="RigidBody3D" node_paths=PackedStringArray("collider")] script = ExtResource("1_ra6j6") +collider = NodePath("CollisionShape3D3") [node name="MeshInstance3D" type="MeshInstance3D" parent="."] material_override = ExtResource("1_ksvsv") diff --git a/Commands/haste_new.png.import b/Commands/haste_new.png.import index 889c8a7..b7309c1 100644 --- a/Commands/haste_new.png.import +++ b/Commands/haste_new.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://dx8s88cut5kka" -path="res://.godot/imported/haste_new.png-0ba91c6aeea5d133877fab9bb8289326.ctex" +path.s3tc="res://.godot/imported/haste_new.png-0ba91c6aeea5d133877fab9bb8289326.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Commands/haste_new.png" -dest_files=["res://.godot/imported/haste_new.png-0ba91c6aeea5d133877fab9bb8289326.ctex"] +dest_files=["res://.godot/imported/haste_new.png-0ba91c6aeea5d133877fab9bb8289326.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ process/normal_map_invert_y=false process/hdr_as_srgb=false process/hdr_clamp_exposure=false process/size_limit=0 -detect_3d/compress_to=1 +detect_3d/compress_to=0 diff --git a/Commands/phase_shift_new.png.import b/Commands/phase_shift_new.png.import index 2c2e22c..a296858 100644 --- a/Commands/phase_shift_new.png.import +++ b/Commands/phase_shift_new.png.import @@ -3,25 +3,26 @@ importer="texture" type="CompressedTexture2D" uid="uid://cxljjpwweuds0" -path="res://.godot/imported/phase_shift_new.png-891079484e26e9cd007d0e1ac60bd618.ctex" +path.s3tc="res://.godot/imported/phase_shift_new.png-891079484e26e9cd007d0e1ac60bd618.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://Commands/phase_shift_new.png" -dest_files=["res://.godot/imported/phase_shift_new.png-891079484e26e9cd007d0e1ac60bd618.ctex"] +dest_files=["res://.godot/imported/phase_shift_new.png-891079484e26e9cd007d0e1ac60bd618.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +32,4 @@ process/normal_map_invert_y=false process/hdr_as_srgb=false process/hdr_clamp_exposure=false process/size_limit=0 -detect_3d/compress_to=1 +detect_3d/compress_to=0 diff --git a/Levels/StartingRoom.tscn b/Levels/StartingRoom.tscn index 6d7e4e5..81b07e6 100644 --- a/Levels/StartingRoom.tscn +++ b/Levels/StartingRoom.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=30 format=3 uid="uid://bojbawyoy11i4"] +[gd_scene load_steps=31 format=3 uid="uid://bojbawyoy11i4"] [ext_resource type="Script" path="res://Scripts/ChronoManager.gd" id="1_5b2rd"] [ext_resource type="Material" uid="uid://cr4ra7ijk1uec" path="res://Assets/Materials/floor.tres" id="2_0aj3l"] @@ -11,7 +11,8 @@ [ext_resource type="Texture2D" uid="uid://dd150xco2ee5q" path="res://Assets/Textures/cobalt_stone_4.png" id="7_qjeey"] [ext_resource type="PackedScene" uid="uid://cq4rfdsc5kghr" path="res://Commands/command_pedestal.tscn" id="10_sghta"] [ext_resource type="Texture2D" uid="uid://vc7wwv4wgabf" path="res://Commands/jump.png" id="10_x6wpo"] -[ext_resource type="Texture2D" uid="uid://cmvnccuywukyw" path="res://Commands/controlled_blink_new.png" id="11_oknde"] +[ext_resource type="Texture2D" uid="uid://cxljjpwweuds0" path="res://Commands/phase_shift_new.png" id="11_olm6e"] +[ext_resource type="Texture2D" uid="uid://dx8s88cut5kka" path="res://Commands/haste_new.png" id="12_3c4u7"] [ext_resource type="AudioStream" uid="uid://jm6vo1vxrlyx" path="res://Assets/62986__radian__chime-0011.wav" id="12_bm4h4"] [sub_resource type="BoxMesh" id="BoxMesh_21vdj"] @@ -160,10 +161,35 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.5, 1.322, -1.5) command_name = "jump" command_sprite = ExtResource("10_x6wpo") -[node name="JumpCommand5" parent="." instance=ExtResource("5_81jk1")] +[node name="PhaseCommand" parent="." instance=ExtResource("5_81jk1")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.5, 1.322, -2.5) command_name = "phase" -command_sprite = ExtResource("11_oknde") +command_sprite = ExtResource("11_olm6e") + +[node name="PhaseCommand2" parent="." instance=ExtResource("5_81jk1")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.5, 1.322, -2.5) +command_name = "phase" +command_sprite = ExtResource("11_olm6e") + +[node name="PhaseCommand3" parent="." instance=ExtResource("5_81jk1")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5, 1.322, -2.5) +command_name = "phase" +command_sprite = ExtResource("11_olm6e") + +[node name="DashCommand" parent="." instance=ExtResource("5_81jk1")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.5, 1.322, -3.5) +command_name = "dash" +command_sprite = ExtResource("12_3c4u7") + +[node name="DashCommand2" parent="." instance=ExtResource("5_81jk1")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.5, 1.322, -3.5) +command_name = "dash" +command_sprite = ExtResource("12_3c4u7") + +[node name="DashCommand3" parent="." instance=ExtResource("5_81jk1")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5, 1.322, -3.5) +command_name = "dash" +command_sprite = ExtResource("12_3c4u7") [node name="Pedestals" type="Node3D" parent="."] diff --git a/Scripts/Player.gd b/Scripts/Player.gd index ef77093..676f33d 100644 --- a/Scripts/Player.gd +++ b/Scripts/Player.gd @@ -14,6 +14,12 @@ signal object_clicked(object : Node3D) var SPEED = 5.0 const JUMP_VELOCITY = 4.5 +#effects +var dash_time = 0 +@export var dash_node : Node3D +var dashing = false + + # Get the gravity from the project settings to be synced with RigidBody nodes. var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") @@ -53,6 +59,7 @@ func _physics_process(delta): held_object.reparent(hand) held_object.position = Vector3(0,0,0) held_object.freeze = true + held_object.collider.disabled = true has_object = true elif "placed_command" in raycast.get_collider(): # clicked a pedestal, place on pedestal if its not already got something @@ -63,6 +70,7 @@ func _physics_process(delta): held_object.reparent(clicked_pedestal.slot) held_object.position = Vector3(0,0,0) held_object.rotation_degrees = Vector3(0,0,0) + held_object.collider.disabled = false has_object = false clicked_pedestal.has_command = true clicked_pedestal.placed_command = held_object @@ -71,6 +79,8 @@ func _physics_process(delta): object_clicked.emit(raycast.get_collider()) else: print("womp womp") + + # Get the input direction and handle the movement/deceleration. @@ -84,6 +94,17 @@ func _physics_process(delta): velocity.x = move_toward(velocity.x, 0, SPEED) velocity.z = move_toward(velocity.z, 0, SPEED) + if (dash_time > 0 ): + gravity = 0 + dash_time -= delta + var dash_direction = camera.global_position.direction_to(dash_node.global_position) + velocity = dash_direction * SPEED*350 * delta + elif dashing: + dashing = false + velocity = Vector3(0,0,0) + gravity = ProjectSettings.get_setting("physics/3d/default_gravity") + pass + move_and_slide() @@ -98,6 +119,7 @@ func drop(): if has_object: held_object.reparent(get_tree().get_root()) held_object.freeze = false + held_object.collider.disabled = false has_object = false @@ -106,8 +128,10 @@ func _on_chrono_manager_broadcast(command): match command: "jump": velocity.y = JUMP_VELOCITY - "teleport": - pass + "dash": + #move in looked direction for 0.5 secs + dash_time = 0.3 + dashing = true "run": SPEED = 10 "phase": diff --git a/TODO.txt b/TODO.txt index db39496..037d301 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,7 +1,11 @@ -- [ ] FPS Controller -- [ ] Chrono terminal -- [ ] commands +- [x] FPS Controller +- [x] Chrono terminal +- [x] commands - [ ] level deign - [ ] level funciton -- [ ] command functions +- [x] command functions - [ ] test camera controls for framerate independance + + +BUGS +- [ ] cant place command block in pedestals which ahs already had one diff --git a/player.tscn b/player.tscn index aaaaf1a..053910b 100644 --- a/player.tscn +++ b/player.tscn @@ -8,13 +8,14 @@ radius = 0.47 height = 1.9 -[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("camera", "raycast", "hand", "collider")] +[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("camera", "raycast", "hand", "collider", "dash_node")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.83982, 0) script = ExtResource("1_tc5d2") camera = NodePath("Camera3D") raycast = NodePath("Camera3D/RayCast3D") hand = NodePath("Camera3D/hand") collider = NodePath("CollisionShape3D") +dash_node = NodePath("Camera3D/DashDirection") [node name="MeshInstance3D2" type="MeshInstance3D" parent="."] mesh = SubResource("CapsuleMesh_5q2rg") @@ -31,5 +32,8 @@ collide_with_areas = true [node name="hand" type="Node3D" parent="Camera3D"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.930871, -0.621505, -0.929852) +[node name="DashDirection" type="Node3D" parent="Camera3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2.0093) + [node name="CollisionShape3D" type="CollisionShape3D" parent="."] shape = SubResource("CapsuleShape3D_a6eig")