Try new perspective for character, minor projectile fixes

This commit is contained in:
2023-09-02 07:46:19 -07:00
parent 829db1adb9
commit b6262e2b1f
12 changed files with 70 additions and 31 deletions

View File

@@ -3,7 +3,7 @@
importer="scene" importer="scene"
importer_version=1 importer_version=1
type="PackedScene" type="PackedScene"
uid="uid://cmj0fo8gufb4y" uid="uid://bckd04543occ5"
path="res://.godot/imported/levelTEST.gltf-f44a90f00154d0b34bded5b045248ca3.scn" path="res://.godot/imported/levelTEST.gltf-f44a90f00154d0b34bded5b045248ca3.scn"
[deps] [deps]

View File

@@ -2,7 +2,7 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://bepybjwwog3dt" uid="uid://bch5ytrxpolnk"
path.s3tc="res://.godot/imported/levelTEST_1000_F_294997483_FrDSBYr8gfJ5OnXF7IomvLjg3jjQldvr.png-54928c9fd7c261ee31a4f147685539e9.s3tc.ctex" path.s3tc="res://.godot/imported/levelTEST_1000_F_294997483_FrDSBYr8gfJ5OnXF7IomvLjg3jjQldvr.png-54928c9fd7c261ee31a4f147685539e9.s3tc.ctex"
metadata={ metadata={
"imported_formats": ["s3tc_bptc"], "imported_formats": ["s3tc_bptc"],

View File

@@ -2,7 +2,7 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://cpv3lagb71i80" uid="uid://cfjna11kkjnx5"
path.s3tc="res://.godot/imported/levelTEST_33312605-seamless-wood-texture-natural-background.png-681f106535acc0b22c3782ca3490e6cb.s3tc.ctex" path.s3tc="res://.godot/imported/levelTEST_33312605-seamless-wood-texture-natural-background.png-681f106535acc0b22c3782ca3490e6cb.s3tc.ctex"
metadata={ metadata={
"imported_formats": ["s3tc_bptc"], "imported_formats": ["s3tc_bptc"],

View File

@@ -2,7 +2,7 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://bw5ap6orpo70c" uid="uid://bj8evqg4oegyw"
path.s3tc="res://.godot/imported/levelTEST_57a4b1dda4796c2d47bb9ed563eddac7.png-bc1900852803938ef03a3564e18e855e.s3tc.ctex" path.s3tc="res://.godot/imported/levelTEST_57a4b1dda4796c2d47bb9ed563eddac7.png-bc1900852803938ef03a3564e18e855e.s3tc.ctex"
metadata={ metadata={
"imported_formats": ["s3tc_bptc"], "imported_formats": ["s3tc_bptc"],

View File

@@ -2,7 +2,7 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://5t0srlfa8ubb" uid="uid://o723ad7k848v"
path.s3tc="res://.godot/imported/levelTEST_Tiling-Grass-Texture-Main.png-3625ac5b5a48e349f48f366367416cdd.s3tc.ctex" path.s3tc="res://.godot/imported/levelTEST_Tiling-Grass-Texture-Main.png-3625ac5b5a48e349f48f366367416cdd.s3tc.ctex"
metadata={ metadata={
"imported_formats": ["s3tc_bptc"], "imported_formats": ["s3tc_bptc"],

9
Scenes/2DTest.tscn Normal file
View File

@@ -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="."]

View File

@@ -11,11 +11,13 @@ material = SubResource("StandardMaterial3D_5vpcx")
[sub_resource type="SphereShape3D" id="SphereShape3D_o6kys"] [sub_resource type="SphereShape3D" id="SphereShape3D_o6kys"]
[node name="ShotgunBullet" type="Node3D"] [node name="ShotgunBullet" type="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.73894, 0)
script = ExtResource("1_binxs") script = ExtResource("1_binxs")
_projectileSpeed = 50.0 Cooldown = 0.5
_projectileSpeed = 15.0
[node name="RigidBody3D" type="RigidBody3D" parent="."] [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_layer = 2
collision_mask = 0 collision_mask = 0
gravity_scale = 0.0 gravity_scale = 0.0
@@ -31,7 +33,7 @@ skeleton = NodePath("../..")
shape = SubResource("SphereShape3D_o6kys") shape = SubResource("SphereShape3D_o6kys")
[node name="RigidBody3D2" type="RigidBody3D" parent="."] [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_layer = 2
collision_mask = 0 collision_mask = 0
gravity_scale = 0.0 gravity_scale = 0.0

View File

@@ -11,8 +11,10 @@ material = SubResource("StandardMaterial3D_phgri")
[sub_resource type="SphereShape3D" id="SphereShape3D_rokeu"] [sub_resource type="SphereShape3D" id="SphereShape3D_rokeu"]
[node name="TestBullet" type="Node3D"] [node name="TestBullet" type="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.538645, 0)
script = ExtResource("1_cavby") script = ExtResource("1_cavby")
_projectileSpeed = 50.0 Cooldown = 0.5
_projectileSpeed = 15.0
[node name="RigidBody3D" type="RigidBody3D" parent="."] [node name="RigidBody3D" type="RigidBody3D" parent="."]
collision_layer = 2 collision_layer = 2

View File

@@ -10,8 +10,9 @@ radius = 0.152487
height = 0.456443 height = 0.456443
[node name="Character" type="CharacterBody3D"] [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") script = ExtResource("1_hddqi")
_speed = 10.0 _speed = 15.0
_fireProjectile = ExtResource("3_ojvu2") _fireProjectile = ExtResource("3_ojvu2")
_altFireProjectile = ExtResource("3_5h4r7") _altFireProjectile = ExtResource("3_5h4r7")

View File

@@ -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://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"] [sub_resource type="BoxShape3D" id="BoxShape3D_iokol"]
size = Vector3(82.1972, 9.85066, 69.234) 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="Level" type="Node3D"]
[node name="Camera3D" type="Camera3D" parent="."] [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) transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.0769171, 40.2411, -32.0601)
fov = 50.0
[node name="DebugCamera" type="Camera3D" parent="."] [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 visible = false
[node name="Fish Witch" parent="." instance=ExtResource("1_fwf6c")] [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="."] [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) 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"] [node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.194912, 0.132027, -36.4269) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -36.9892)
shape = SubResource("BoxShape3D_wrrav") 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")

View File

@@ -9,27 +9,35 @@ public partial class TestCharacter : CharacterBody3D
[Export] [Export]
private PackedScene _altFireProjectile; private PackedScene _altFireProjectile;
public bool CanShoot { get; private set; }
public override void _Ready()
{
CanShoot = true;
}
public override void _PhysicsProcess(double delta) public override void _PhysicsProcess(double delta)
{ {
if (Input.IsActionJustPressed("p1_fire")) if (Input.IsActionJustPressed("p1_fire") && CanShoot)
Fire(); Fire();
if (Input.IsActionJustPressed("p1_altfire")) if (Input.IsActionJustPressed("p1_altfire") && CanShoot)
AltFire(); AltFire();
Velocity = CalculateCharacterMovement(); Velocity = CalculateCharacterMovement(delta);
MoveAndSlide(); MoveAndSlide();
} }
private Vector3 CalculateCharacterMovement() private Vector3 CalculateCharacterMovement(double delta)
{ {
var velocity = Velocity; var velocity = Velocity;
var inputDir = Input.GetVector("p1_left", "p1_right", "p1_up", "p1_down"); var inputDir = Input.GetVector("p1_left", "p1_right", "p1_up", "p1_down");
var direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized(); var direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
if (direction != Vector3.Zero) if (direction != Vector3.Zero)
{ {
velocity.X = direction.X * _speed; velocity.X = direction.X * _speed;
velocity.Z = direction.Z * _speed; velocity.Z = direction.Z * _speed * 2;
GetNode<Node3D>("Pivot").LookAt(Position + direction, Vector3.Up); GetNode<Node3D>("Pivot").LookAt(Position + direction, Vector3.Forward);
} }
else else
{ {
@@ -42,16 +50,20 @@ public partial class TestCharacter : CharacterBody3D
private async void Fire() private async void Fire()
{ {
var projectile = _fireProjectile.Instantiate<Projectile>(); var projectile = _fireProjectile.Instantiate<Projectile>();
projectile.Position = Position + new Vector3(0f, 0f, -0.2f); projectile.Position = Position + new Vector3(0f, 1f, -1f);
GetParent().AddChild(projectile); GetParent().AddChild(projectile);
CanShoot = false;
await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout"); await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout");
CanShoot = true;
} }
private async void AltFire() private async void AltFire()
{ {
var projectile = _altFireProjectile.Instantiate<Projectile>(); var projectile = _altFireProjectile.Instantiate<Projectile>();
projectile.Position = Position + new Vector3(0f, 0f, -0.2f); projectile.Position = Position + new Vector3(0f, 1f, -1f);
GetParent().AddChild(projectile); GetParent().AddChild(projectile);
CanShoot = false;
await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout"); await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout");
CanShoot = true;
} }
} }

View File

@@ -17,7 +17,7 @@ config/features=PackedStringArray("4.1", "C#", "Forward Plus")
[display] [display]
window/size/viewport_width=1920 window/size/viewport_width=1920
window/size/viewport_height=1440 window/size/viewport_height=1400
[dotnet] [dotnet]