From b6262e2b1fab1b2afb46ff6be42f5e38b16852e5 Mon Sep 17 00:00:00 2001 From: Zenny Date: Sat, 2 Sep 2023 07:46:19 -0700 Subject: [PATCH] Try new perspective for character, minor projectile fixes --- Levels/levelTEST.gltf.import | 2 +- ...rDSBYr8gfJ5OnXF7IomvLjg3jjQldvr.png.import | 2 +- ...wood-texture-natural-background.png.import | 2 +- ...7a4b1dda4796c2d47bb9ed563eddac7.png.import | 2 +- ...lTEST_Tiling-Grass-Texture-Main.png.import | 2 +- Scenes/2DTest.tscn | 9 +++++ Scenes/ShotgunBullet.tscn | 8 ++-- Scenes/TestBullet.tscn | 4 +- Scenes/TestCharacter.tscn | 3 +- Scenes/TestLevel.tscn | 37 +++++++++++++------ Scripts/TestCharacter.cs | 28 ++++++++++---- project.godot | 2 +- 12 files changed, 70 insertions(+), 31 deletions(-) create mode 100644 Scenes/2DTest.tscn diff --git a/Levels/levelTEST.gltf.import b/Levels/levelTEST.gltf.import index 0489109..44de006 100644 --- a/Levels/levelTEST.gltf.import +++ b/Levels/levelTEST.gltf.import @@ -3,7 +3,7 @@ importer="scene" importer_version=1 type="PackedScene" -uid="uid://cmj0fo8gufb4y" +uid="uid://bckd04543occ5" path="res://.godot/imported/levelTEST.gltf-f44a90f00154d0b34bded5b045248ca3.scn" [deps] diff --git a/Levels/levelTEST_1000_F_294997483_FrDSBYr8gfJ5OnXF7IomvLjg3jjQldvr.png.import b/Levels/levelTEST_1000_F_294997483_FrDSBYr8gfJ5OnXF7IomvLjg3jjQldvr.png.import index a1974a5..1b90d69 100644 --- a/Levels/levelTEST_1000_F_294997483_FrDSBYr8gfJ5OnXF7IomvLjg3jjQldvr.png.import +++ b/Levels/levelTEST_1000_F_294997483_FrDSBYr8gfJ5OnXF7IomvLjg3jjQldvr.png.import @@ -2,7 +2,7 @@ importer="texture" type="CompressedTexture2D" -uid="uid://bepybjwwog3dt" +uid="uid://bch5ytrxpolnk" path.s3tc="res://.godot/imported/levelTEST_1000_F_294997483_FrDSBYr8gfJ5OnXF7IomvLjg3jjQldvr.png-54928c9fd7c261ee31a4f147685539e9.s3tc.ctex" metadata={ "imported_formats": ["s3tc_bptc"], diff --git a/Levels/levelTEST_33312605-seamless-wood-texture-natural-background.png.import b/Levels/levelTEST_33312605-seamless-wood-texture-natural-background.png.import index 281dac6..790135f 100644 --- a/Levels/levelTEST_33312605-seamless-wood-texture-natural-background.png.import +++ b/Levels/levelTEST_33312605-seamless-wood-texture-natural-background.png.import @@ -2,7 +2,7 @@ importer="texture" type="CompressedTexture2D" -uid="uid://cpv3lagb71i80" +uid="uid://cfjna11kkjnx5" path.s3tc="res://.godot/imported/levelTEST_33312605-seamless-wood-texture-natural-background.png-681f106535acc0b22c3782ca3490e6cb.s3tc.ctex" metadata={ "imported_formats": ["s3tc_bptc"], diff --git a/Levels/levelTEST_57a4b1dda4796c2d47bb9ed563eddac7.png.import b/Levels/levelTEST_57a4b1dda4796c2d47bb9ed563eddac7.png.import index 1bef074..6ac407a 100644 --- a/Levels/levelTEST_57a4b1dda4796c2d47bb9ed563eddac7.png.import +++ b/Levels/levelTEST_57a4b1dda4796c2d47bb9ed563eddac7.png.import @@ -2,7 +2,7 @@ importer="texture" type="CompressedTexture2D" -uid="uid://bw5ap6orpo70c" +uid="uid://bj8evqg4oegyw" path.s3tc="res://.godot/imported/levelTEST_57a4b1dda4796c2d47bb9ed563eddac7.png-bc1900852803938ef03a3564e18e855e.s3tc.ctex" metadata={ "imported_formats": ["s3tc_bptc"], diff --git a/Levels/levelTEST_Tiling-Grass-Texture-Main.png.import b/Levels/levelTEST_Tiling-Grass-Texture-Main.png.import index fb60545..bfbd31e 100644 --- a/Levels/levelTEST_Tiling-Grass-Texture-Main.png.import +++ b/Levels/levelTEST_Tiling-Grass-Texture-Main.png.import @@ -2,7 +2,7 @@ importer="texture" type="CompressedTexture2D" -uid="uid://5t0srlfa8ubb" +uid="uid://o723ad7k848v" path.s3tc="res://.godot/imported/levelTEST_Tiling-Grass-Texture-Main.png-3625ac5b5a48e349f48f366367416cdd.s3tc.ctex" metadata={ "imported_formats": ["s3tc_bptc"], diff --git a/Scenes/2DTest.tscn b/Scenes/2DTest.tscn new file mode 100644 index 0000000..b152ac1 --- /dev/null +++ b/Scenes/2DTest.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=3 uid="uid://0em7im554tr4"] + +[ext_resource type="PackedScene" uid="uid://d3m6e5iduqxhh" path="res://Levels/levelTEST-col.gltf" id="1_fyfwj"] + +[node name="2DTest" type="Node2D"] + +[node name="levelTEST-col" parent="." instance=ExtResource("1_fyfwj")] + +[node name="Camera2D" type="Camera2D" parent="."] diff --git a/Scenes/ShotgunBullet.tscn b/Scenes/ShotgunBullet.tscn index 0406c66..c3cbc1f 100644 --- a/Scenes/ShotgunBullet.tscn +++ b/Scenes/ShotgunBullet.tscn @@ -11,11 +11,13 @@ material = SubResource("StandardMaterial3D_5vpcx") [sub_resource type="SphereShape3D" id="SphereShape3D_o6kys"] [node name="ShotgunBullet" type="Node3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.73894, 0) script = ExtResource("1_binxs") -_projectileSpeed = 50.0 +Cooldown = 0.5 +_projectileSpeed = 15.0 [node name="RigidBody3D" type="RigidBody3D" parent="."] -transform = Transform3D(0.996195, 0, -0.0871557, 0, 1, 0, 0.0871557, 0, 0.996195, -1.27456, 0, 0) +transform = Transform3D(0.99863, 0, -0.052336, 0, 1, 0, 0.052336, 0, 0.99863, -1.27456, 0, 0) collision_layer = 2 collision_mask = 0 gravity_scale = 0.0 @@ -31,7 +33,7 @@ skeleton = NodePath("../..") shape = SubResource("SphereShape3D_o6kys") [node name="RigidBody3D2" type="RigidBody3D" parent="."] -transform = Transform3D(0.996195, 0, 0.0871557, 0, 1, 0, -0.0871557, 0, 0.996195, 1.32, 0, 0) +transform = Transform3D(0.99863, 0, 0.052336, 0, 1, 0, -0.052336, 0, 0.99863, 1.32, 0, 0) collision_layer = 2 collision_mask = 0 gravity_scale = 0.0 diff --git a/Scenes/TestBullet.tscn b/Scenes/TestBullet.tscn index d4ae464..b2a21bb 100644 --- a/Scenes/TestBullet.tscn +++ b/Scenes/TestBullet.tscn @@ -11,8 +11,10 @@ material = SubResource("StandardMaterial3D_phgri") [sub_resource type="SphereShape3D" id="SphereShape3D_rokeu"] [node name="TestBullet" type="Node3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.538645, 0) script = ExtResource("1_cavby") -_projectileSpeed = 50.0 +Cooldown = 0.5 +_projectileSpeed = 15.0 [node name="RigidBody3D" type="RigidBody3D" parent="."] collision_layer = 2 diff --git a/Scenes/TestCharacter.tscn b/Scenes/TestCharacter.tscn index a9b044c..ab9ed84 100644 --- a/Scenes/TestCharacter.tscn +++ b/Scenes/TestCharacter.tscn @@ -10,8 +10,9 @@ radius = 0.152487 height = 0.456443 [node name="Character" type="CharacterBody3D"] +transform = Transform3D(1, 0, 0, 0, 0.884801, 0.46597, 0, -0.46597, 0.884801, 0, 0, 0) script = ExtResource("1_hddqi") -_speed = 10.0 +_speed = 15.0 _fireProjectile = ExtResource("3_ojvu2") _altFireProjectile = ExtResource("3_5h4r7") diff --git a/Scenes/TestLevel.tscn b/Scenes/TestLevel.tscn index e05401c..1e4b090 100644 --- a/Scenes/TestLevel.tscn +++ b/Scenes/TestLevel.tscn @@ -1,29 +1,42 @@ -[gd_scene load_steps=4 format=3 uid="uid://dy3d4e6qegyjg"] +[gd_scene load_steps=5 format=3 uid="uid://dy3d4e6qegyjg"] [ext_resource type="PackedScene" uid="uid://b38hcomu4tpm5" path="res://Scenes/TestCharacter.tscn" id="1_fwf6c"] -[ext_resource type="PackedScene" uid="uid://cmj0fo8gufb4y" path="res://Levels/levelTEST.gltf" id="2_afl3s"] +[ext_resource type="PackedScene" uid="uid://bckd04543occ5" path="res://Levels/levelTEST.gltf" id="2_afl3s"] -[sub_resource type="BoxShape3D" id="BoxShape3D_wrrav"] -size = Vector3(82.1972, 9.85066, 69.234) +[sub_resource type="BoxShape3D" id="BoxShape3D_iokol"] +size = Vector3(77.2254, 10, 63.5656) + +[sub_resource type="BoxShape3D" id="BoxShape3D_hr26o"] +size = Vector3(37.611, 23.269, 13.2547) [node name="Level" type="Node3D"] [node name="Camera3D" type="Camera3D" parent="."] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.0769171, 67.1716, -34.2862) -fov = 50.0 +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.0769171, 40.2411, -32.0601) [node name="DebugCamera" type="Camera3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 0.821149, 0.570714, 0, -0.570714, 0.821149, -0.36148, 1.40359, 0.864433) +transform = Transform3D(1, 0, 0, 0, 0.821149, 0.570714, 0, -0.570714, 0.821149, -0.36148, 17.9168, 0.864431) visible = false [node name="Fish Witch" parent="." instance=ExtResource("1_fwf6c")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.56447, -7.95901) +transform = Transform3D(1, 0, 0, 0, 0.34202, 0.939692, 0, -0.939692, 0.34202, 5.26031, 4.56447, -7.95901) +_speed = 10.0 [node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] transform = Transform3D(-0.931845, -0.0850834, 0.35274, -0.0909281, 0.995857, -1.47234e-08, -0.351279, -0.032074, -0.935721, -3.58319, 8.01249, 0.163277) -[node name="levelTEST" parent="." instance=ExtResource("2_afl3s")] +[node name="StaticBody3D" type="StaticBody3D" parent="."] -[node name="CollisionShape3D" type="CollisionShape3D" parent="levelTEST"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.194912, 0.132027, -36.4269) -shape = SubResource("BoxShape3D_wrrav") +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -36.9892) +shape = SubResource("BoxShape3D_iokol") + +[node name="levelTEST" parent="StaticBody3D" instance=ExtResource("2_afl3s")] + +[node name="CollisionShape3D3" type="CollisionShape3D" parent="StaticBody3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 22.6611, 4.08253, -30.6854) +shape = SubResource("BoxShape3D_hr26o") + +[node name="CollisionShape3D2" type="CollisionShape3D" parent="StaticBody3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -22.9547, 1.81661, -31.6168) +shape = SubResource("BoxShape3D_hr26o") diff --git a/Scripts/TestCharacter.cs b/Scripts/TestCharacter.cs index 008072f..7cf1622 100644 --- a/Scripts/TestCharacter.cs +++ b/Scripts/TestCharacter.cs @@ -9,27 +9,35 @@ public partial class TestCharacter : CharacterBody3D [Export] private PackedScene _altFireProjectile; + public bool CanShoot { get; private set; } + + public override void _Ready() + { + CanShoot = true; + } + public override void _PhysicsProcess(double delta) { - if (Input.IsActionJustPressed("p1_fire")) + if (Input.IsActionJustPressed("p1_fire") && CanShoot) Fire(); - if (Input.IsActionJustPressed("p1_altfire")) + if (Input.IsActionJustPressed("p1_altfire") && CanShoot) AltFire(); - Velocity = CalculateCharacterMovement(); + Velocity = CalculateCharacterMovement(delta); MoveAndSlide(); } - private Vector3 CalculateCharacterMovement() + private Vector3 CalculateCharacterMovement(double delta) { var velocity = Velocity; + var inputDir = Input.GetVector("p1_left", "p1_right", "p1_up", "p1_down"); var direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized(); if (direction != Vector3.Zero) { velocity.X = direction.X * _speed; - velocity.Z = direction.Z * _speed; - GetNode("Pivot").LookAt(Position + direction, Vector3.Up); + velocity.Z = direction.Z * _speed * 2; + GetNode("Pivot").LookAt(Position + direction, Vector3.Forward); } else { @@ -42,16 +50,20 @@ public partial class TestCharacter : CharacterBody3D private async void Fire() { var projectile = _fireProjectile.Instantiate(); - projectile.Position = Position + new Vector3(0f, 0f, -0.2f); + projectile.Position = Position + new Vector3(0f, 1f, -1f); GetParent().AddChild(projectile); + CanShoot = false; await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout"); + CanShoot = true; } private async void AltFire() { var projectile = _altFireProjectile.Instantiate(); - projectile.Position = Position + new Vector3(0f, 0f, -0.2f); + projectile.Position = Position + new Vector3(0f, 1f, -1f); GetParent().AddChild(projectile); + CanShoot = false; await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout"); + CanShoot = true; } } diff --git a/project.godot b/project.godot index f8daa53..d0df686 100644 --- a/project.godot +++ b/project.godot @@ -17,7 +17,7 @@ config/features=PackedStringArray("4.1", "C#", "Forward Plus") [display] window/size/viewport_width=1920 -window/size/viewport_height=1440 +window/size/viewport_height=1400 [dotnet]