Player spawn
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://b38hcomu4tpm5"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://b38hcomu4tpm5"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/TestCharacter.cs" id="1_hddqi"]
|
||||
[ext_resource type="PackedScene" uid="uid://bq40xbqibrk1y" path="res://Scenes/ShotgunBullet.tscn" id="3_5h4r7"]
|
||||
[ext_resource type="PackedScene" uid="uid://si4byubqnng4" path="res://Scenes/TestBullet.tscn" id="3_ojvu2"]
|
||||
[ext_resource type="PackedScene" uid="uid://yosw0j58nvrf" path="res://Models/Characters/fwitch.gltf" id="4_n3637"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_ayco3"]
|
||||
@@ -15,25 +13,23 @@ height = 1.67894
|
||||
|
||||
[node name="Character" type="CharacterBody3D"]
|
||||
script = ExtResource("1_hddqi")
|
||||
_speed = 15.0
|
||||
_fireProjectile = ExtResource("3_ojvu2")
|
||||
_altFireProjectile = ExtResource("3_5h4r7")
|
||||
|
||||
[node name="Pivot" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.5, 0.866025, 0, -0.866025, 0.5, 0, 0, 0)
|
||||
|
||||
[node name="fwitch" parent="Pivot" instance=ExtResource("4_n3637")]
|
||||
|
||||
[node name="Area3D" type="Area3D" parent="."]
|
||||
[node name="Area3D" type="Area3D" parent="Pivot"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.75657e-15, 0, 0)
|
||||
collision_layer = 0
|
||||
collision_mask = 4
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Pivot/Area3D"]
|
||||
transform = Transform3D(0.999665, -0.0258978, -7.10543e-15, 0.0258978, 0.999665, 0, 0, 0, 1, -0.0242356, 2.05297, -0.302385)
|
||||
shape = SubResource("CapsuleShape3D_ayco3")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(0.999665, -0.0258978, -7.10543e-15, 0.0258978, 0.999665, 0, 0, 0, 1, 0, 2.10024, -0.247215)
|
||||
transform = Transform3D(1, 0, 0, 0, 0.5, 0.866025, 0, -0.866026, 0.5, 0, 1.46483, 0)
|
||||
shape = SubResource("CapsuleShape3D_fqik1")
|
||||
|
||||
[connection signal="body_entered" from="Area3D" to="." method="OnHit"]
|
||||
[connection signal="body_entered" from="Pivot/Area3D" to="." method="OnHit"]
|
||||
|
||||
16
Scenes/TestLevel.cs
Normal file
16
Scenes/TestLevel.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Godot;
|
||||
|
||||
public partial class TestLevel : Node3D
|
||||
{
|
||||
[Export]
|
||||
private Marker3D _spawnPoint;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
var players = GetTree().GetNodesInGroup("Player");
|
||||
foreach (TestCharacter player in players)
|
||||
{
|
||||
player.Transform = _spawnPoint.Transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://dy3d4e6qegyjg"]
|
||||
[gd_scene load_steps=13 format=3 uid="uid://dy3d4e6qegyjg"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b38hcomu4tpm5" path="res://Scenes/TestCharacter.tscn" id="1_fwf6c"]
|
||||
[ext_resource type="Script" path="res://Scenes/TestLevel.cs" id="1_q0cc6"]
|
||||
[ext_resource type="PackedScene" uid="uid://bckd04543occ5" path="res://Levels/levelTEST.gltf" id="2_afl3s"]
|
||||
[ext_resource type="PackedScene" uid="uid://dkjdt7uq3a4j3" path="res://Scenes/TestEnemy.tscn" id="3_ds7vi"]
|
||||
[ext_resource type="PackedScene" uid="uid://si4byubqnng4" path="res://Scenes/TestBullet.tscn" id="3_lmb02"]
|
||||
[ext_resource type="PackedScene" uid="uid://bq40xbqibrk1y" path="res://Scenes/ShotgunBullet.tscn" id="4_t522c"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_iokol"]
|
||||
size = Vector3(77.2254, 10, 63.5656)
|
||||
@@ -14,7 +17,8 @@ size = Vector3(37.611, 23.269, 13.2547)
|
||||
size = Vector3(100, 100, 18.6922)
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_lhgew"]
|
||||
radius = 1.42751
|
||||
height = 7.44995
|
||||
radius = 1.45911
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_fa41j"]
|
||||
height = 4.6719
|
||||
@@ -24,7 +28,9 @@ radius = 2.32337
|
||||
height = 5.0
|
||||
radius = 2.06347
|
||||
|
||||
[node name="Level" type="Node3D"]
|
||||
[node name="Level" type="Node3D" node_paths=PackedStringArray("_spawnPoint")]
|
||||
script = ExtResource("1_q0cc6")
|
||||
_spawnPoint = NodePath("SpawnPoint")
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 0, 1, 0, -1, 0, -0.0769171, 95.2611, -32.0601)
|
||||
@@ -34,8 +40,10 @@ fov = 30.0
|
||||
transform = Transform3D(1, 0, 0, 0, 0.821149, 0.570714, 0, -0.570714, 0.821149, -0.36148, 22.6449, 10.8421)
|
||||
|
||||
[node name="Fish Witch" parent="." groups=["Player"] instance=ExtResource("1_fwf6c")]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.5, 0.866025, 0, -0.866025, 0.5, 5.26, 5.13104, -7.959)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 40.7459)
|
||||
_speed = 10.0
|
||||
_fireProjectile = ExtResource("3_lmb02")
|
||||
_altFireProjectile = ExtResource("4_t522c")
|
||||
|
||||
[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)
|
||||
@@ -76,17 +84,20 @@ shape = SubResource("BoxShape3D_sjyl3")
|
||||
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -48.9058, -1.95573, -40.25)
|
||||
shape = SubResource("BoxShape3D_sjyl3")
|
||||
|
||||
[node name="CollisionShape3D9" type="CollisionShape3D" parent="StaticBody3D"]
|
||||
[node name="Rock1" type="CollisionShape3D" parent="StaticBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.93645, 5.82082, -21.6909)
|
||||
shape = SubResource("CylinderShape3D_lhgew")
|
||||
|
||||
[node name="CollisionShape3D10" type="CollisionShape3D" parent="StaticBody3D"]
|
||||
[node name="Rock2" type="CollisionShape3D" parent="StaticBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6.82773, 6.46042, -40.6232)
|
||||
shape = SubResource("CylinderShape3D_fa41j")
|
||||
|
||||
[node name="CollisionShape3D11" type="CollisionShape3D" parent="StaticBody3D"]
|
||||
[node name="Rock3" type="CollisionShape3D" parent="StaticBody3D"]
|
||||
transform = Transform3D(0.999841, -0.0178538, 0, 0.0178538, 0.999841, 0, 0, 0, 1, -6.84036, 6.33278, -46.1737)
|
||||
shape = SubResource("CylinderShape3D_krlem")
|
||||
|
||||
[node name="TestEnemy" parent="." instance=ExtResource("3_ds7vi")]
|
||||
transform = Transform3D(0.998405, 0.0226647, 0.0517184, -0.0544217, 0.630486, 0.77429, -0.0150588, -0.775869, 0.630714, -20.5579, 5.52246, -43.2246)
|
||||
|
||||
[node name="SpawnPoint" type="Marker3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.757998, 6.71652, -10.4768)
|
||||
|
||||
@@ -36,13 +36,14 @@ public partial class TestCharacter : CharacterBody3D
|
||||
if (direction != Vector3.Zero)
|
||||
{
|
||||
velocity.X = direction.X * _speed;
|
||||
velocity.Z = direction.Z * _speed * 2;
|
||||
velocity.Z = direction.Z * _speed;
|
||||
GetNode<Node3D>("Pivot").LookAt(Position + direction, Vector3.Forward + Vector3.Up);
|
||||
GetNode<Node3D>("CollisionShape3D").LookAt(Position + direction, Vector3.Forward + Vector3.Up);
|
||||
}
|
||||
else
|
||||
{
|
||||
velocity.X = Mathf.MoveToward(Velocity.X, 0, _speed);
|
||||
velocity.Z = Mathf.MoveToward(Velocity.Z, 0, _speed * 2);
|
||||
velocity.Z = Mathf.MoveToward(Velocity.Z, 0, _speed);
|
||||
}
|
||||
return velocity;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user