add attacks and death
This commit is contained in:
+24
-1
@@ -20,6 +20,12 @@ properties/1/replication_mode = 1
|
|||||||
properties/2/path = NodePath(".:server_rotation")
|
properties/2/path = NodePath(".:server_rotation")
|
||||||
properties/2/spawn = true
|
properties/2/spawn = true
|
||||||
properties/2/replication_mode = 1
|
properties/2/replication_mode = 1
|
||||||
|
properties/3/path = NodePath("RotationBase/Attack:visible")
|
||||||
|
properties/3/spawn = true
|
||||||
|
properties/3/replication_mode = 1
|
||||||
|
properties/4/path = NodePath(".:dead")
|
||||||
|
properties/4/spawn = true
|
||||||
|
properties/4/replication_mode = 1
|
||||||
|
|
||||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_1agtp"]
|
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_1agtp"]
|
||||||
properties/0/path = NodePath("Input:direction")
|
properties/0/path = NodePath("Input:direction")
|
||||||
@@ -77,6 +83,7 @@ unique_name_in_owner = true
|
|||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
|
||||||
|
|
||||||
[node name="Collider" type="CollisionShape3D" parent="."]
|
[node name="Collider" type="CollisionShape3D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||||
shape = SubResource("CapsuleShape3D_j6tb3")
|
shape = SubResource("CapsuleShape3D_j6tb3")
|
||||||
|
|
||||||
@@ -105,8 +112,9 @@ transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, -0.1, 0.6, -0.25)
|
|||||||
mesh = SubResource("SphereMesh_1gltg")
|
mesh = SubResource("SphereMesh_1gltg")
|
||||||
|
|
||||||
[node name="Attack" type="Area3D" parent="RotationBase"]
|
[node name="Attack" type="Area3D" parent="RotationBase"]
|
||||||
|
unique_name_in_owner = true
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -0.75)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -0.75)
|
||||||
monitoring = false
|
visible = false
|
||||||
monitorable = false
|
monitorable = false
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="RotationBase/Attack"]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="RotationBase/Attack"]
|
||||||
@@ -117,6 +125,19 @@ transparency = 0.8
|
|||||||
mesh = SubResource("BoxMesh_phaav")
|
mesh = SubResource("BoxMesh_phaav")
|
||||||
surface_material_override/0 = SubResource("StandardMaterial3D_ssauw")
|
surface_material_override/0 = SubResource("StandardMaterial3D_ssauw")
|
||||||
|
|
||||||
|
[node name="AttackTimer" type="Timer" parent="RotationBase/Attack"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
process_callback = 0
|
||||||
|
wait_time = 0.35
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="AttackCooldown" type="Timer" parent="RotationBase/Attack"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
process_callback = 0
|
||||||
|
wait_time = 2.0
|
||||||
|
one_shot = true
|
||||||
|
autostart = true
|
||||||
|
|
||||||
[node name="FloatingCamera" type="Node" parent="."]
|
[node name="FloatingCamera" type="Node" parent="."]
|
||||||
|
|
||||||
[node name="CameraPlatform" type="Node3D" parent="FloatingCamera"]
|
[node name="CameraPlatform" type="Node3D" parent="FloatingCamera"]
|
||||||
@@ -154,3 +175,5 @@ unique_name_in_owner = true
|
|||||||
script = ExtResource("9_nqccg")
|
script = ExtResource("9_nqccg")
|
||||||
|
|
||||||
[connection signal="delta_synchronized" from="Sync" to="." method="_on_sync_delta_synchronized"]
|
[connection signal="delta_synchronized" from="Sync" to="." method="_on_sync_delta_synchronized"]
|
||||||
|
[connection signal="body_entered" from="RotationBase/Attack" to="StateMachine/Lunge" method="_on_attack_body_entered"]
|
||||||
|
[connection signal="body_exited" from="RotationBase/Attack" to="StateMachine/Lunge" method="_on_attack_body_exited"]
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ properties/1/replication_mode = 1
|
|||||||
properties/2/path = NodePath(".:server_rotation")
|
properties/2/path = NodePath(".:server_rotation")
|
||||||
properties/2/spawn = true
|
properties/2/spawn = true
|
||||||
properties/2/replication_mode = 1
|
properties/2/replication_mode = 1
|
||||||
|
properties/3/path = NodePath(".:dead")
|
||||||
|
properties/3/spawn = true
|
||||||
|
properties/3/replication_mode = 1
|
||||||
|
|
||||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_1agtp"]
|
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_1agtp"]
|
||||||
properties/0/path = NodePath("Input:direction")
|
properties/0/path = NodePath("Input:direction")
|
||||||
@@ -68,6 +71,7 @@ unique_name_in_owner = true
|
|||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
|
||||||
|
|
||||||
[node name="Collider" type="CollisionShape3D" parent="."]
|
[node name="Collider" type="CollisionShape3D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||||
shape = SubResource("CapsuleShape3D_j6tb3")
|
shape = SubResource("CapsuleShape3D_j6tb3")
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -29,11 +29,14 @@ extends CharacterBody3D
|
|||||||
@export_group("Server variables")
|
@export_group("Server variables")
|
||||||
@export var server_position := Vector3.ZERO
|
@export var server_position := Vector3.ZERO
|
||||||
@export var server_rotation := Vector3.ZERO
|
@export var server_rotation := Vector3.ZERO
|
||||||
|
@export var player := true
|
||||||
|
@export var dead := false
|
||||||
|
|
||||||
@onready var _camera_pivot: Node3D = %CameraPivot
|
@onready var _camera_pivot: Node3D = %CameraPivot
|
||||||
@onready var _camera_platform: Node3D = %CameraPlatform
|
@onready var _camera_platform: Node3D = %CameraPlatform
|
||||||
@onready var _camera: Node3D = %Camera
|
@onready var _camera: Node3D = %Camera
|
||||||
@onready var rotation_base: Node3D = %RotationBase
|
@onready var rotation_base: Node3D = %RotationBase
|
||||||
|
@onready var collider: Node3D = %Collider
|
||||||
|
|
||||||
var camera_input_direction := Vector2.ZERO
|
var camera_input_direction := Vector2.ZERO
|
||||||
var last_direction := Vector3.FORWARD
|
var last_direction := Vector3.FORWARD
|
||||||
@@ -108,9 +111,9 @@ func _on_sync_delta_synchronized() -> void:
|
|||||||
position = server_position
|
position = server_position
|
||||||
|
|
||||||
|
|
||||||
func apply_input_velocity(delta: float, input_direction: Vector2, speed: float, acceleration: float) -> void:
|
func apply_input_velocity(delta: float, input_direction: Vector2, speed: float, acc: float) -> void:
|
||||||
var target_velocity = Vector3(input_direction.x * speed, velocity.y, input_direction.y * speed)
|
var target_velocity = Vector3(input_direction.x * speed, velocity.y, input_direction.y * speed)
|
||||||
velocity = velocity.move_toward(target_velocity, acceleration * delta) + Main.gravity_velocity
|
velocity = velocity.move_toward(target_velocity, acc * delta) + Main.gravity_velocity
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
if input_direction.length() >= 0.1:
|
if input_direction.length() >= 0.1:
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
extends State
|
extends State
|
||||||
|
|
||||||
func enter() -> void:
|
func enter() -> void:
|
||||||
|
super()
|
||||||
subject.rotation_base.global_rotation.z = PI / 2
|
subject.rotation_base.global_rotation.z = PI / 2
|
||||||
|
subject.collider.disabled = true
|
||||||
|
|
||||||
func exit() -> void:
|
func exit() -> void:
|
||||||
|
super()
|
||||||
subject.rotation_base.global_rotation.z = 0
|
subject.rotation_base.global_rotation.z = 0
|
||||||
|
subject.collider.disabled = false
|
||||||
|
|
||||||
func process_physics(_delta: float) -> State:
|
func process_physics(_delta: float) -> State:
|
||||||
if not multiplayer.is_server(): return
|
if not multiplayer.is_server(): return
|
||||||
|
if not subject.dead: return %Idle
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ func process_physics(delta: float) -> State:
|
|||||||
subject.apply_input_velocity(delta, Vector2.ZERO, 0.0, subject.air_deceleration)
|
subject.apply_input_velocity(delta, Vector2.ZERO, 0.0, subject.air_deceleration)
|
||||||
|
|
||||||
if not subject.is_on_floor(): return
|
if not subject.is_on_floor(): return
|
||||||
|
if has_node("%Dead") and subject.dead: return %Dead
|
||||||
if %Input.direction.length() < 0.05: return %Idle
|
if %Input.direction.length() < 0.05: return %Idle
|
||||||
if has_node("%Walk") and %Input.walk: return %Walk
|
if has_node("%Walk") and %Input.walk: return %Walk
|
||||||
return %Run
|
return %Run
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ extends State
|
|||||||
func process_physics(delta: float) -> State:
|
func process_physics(delta: float) -> State:
|
||||||
if not Main.is_server_or_predicting(subject.player_id, subject.client_prediction): return
|
if not Main.is_server_or_predicting(subject.player_id, subject.client_prediction): return
|
||||||
|
|
||||||
|
var input_direction = %Input.direction
|
||||||
subject.apply_input_velocity(delta, Vector2.ZERO, 0.0, subject.acceleration)
|
subject.apply_input_velocity(delta, Vector2.ZERO, 0.0, subject.acceleration)
|
||||||
|
|
||||||
if not subject.is_on_floor(): return %Fall
|
if not subject.is_on_floor(): return %Fall
|
||||||
if has_node("%Lunge") and %Input.primary_interact: return %Lunge # TODO: Lunge attacks currently do nothing so Chasers can't move when they click in
|
if has_node("%Dead") and subject.dead: return %Dead
|
||||||
|
if has_node("%Lunge") and %Input.primary_interact and (not has_node("%AttackCooldown") or %AttackCooldown.time_left == 0): return %Lunge
|
||||||
var input_direction = %Input.direction
|
|
||||||
if input_direction.length() < 0.05: return
|
if input_direction.length() < 0.05: return
|
||||||
if has_node("%Walk") and %Input.walk: return %Walk
|
if has_node("%Walk") and %Input.walk: return %Walk
|
||||||
return %Run
|
return %Run
|
||||||
|
|||||||
+33
-2
@@ -1,11 +1,42 @@
|
|||||||
extends State
|
extends State
|
||||||
|
|
||||||
|
var hit = false
|
||||||
|
var players_in_area = {}
|
||||||
|
|
||||||
|
func enter() -> void:
|
||||||
|
super()
|
||||||
|
if has_node("%Attack"): %Attack.visible = true
|
||||||
|
if has_node("%AttackTimer"): %AttackTimer.start()
|
||||||
|
if has_node("%AttackCooldown"): %AttackCooldown.start()
|
||||||
|
hit = false
|
||||||
|
|
||||||
|
func exit() -> void:
|
||||||
|
super()
|
||||||
|
if has_node("%Attack"): %Attack.visible = false
|
||||||
|
|
||||||
func process_physics(delta: float) -> State:
|
func process_physics(delta: float) -> State:
|
||||||
if not Main.is_server_or_predicting(subject.player_id, subject.client_prediction): return
|
if not Main.is_server_or_predicting(subject.player_id, subject.client_prediction): return
|
||||||
|
|
||||||
var input_direction = %Input.direction if subject.is_on_floor() else Vector2.ZERO
|
var input_direction = %Input.direction if subject.is_on_floor() else Vector2.ZERO
|
||||||
|
|
||||||
subject.apply_input_velocity(delta, input_direction, subject.run_speed, subject.acceleration if subject.is_on_floor() else subject.air_deceleration)
|
subject.apply_input_velocity(delta, input_direction, subject.run_speed, subject.acceleration if subject.is_on_floor() else subject.air_deceleration)
|
||||||
|
|
||||||
|
if players_in_area.size() > 0:
|
||||||
|
var hit_player = players_in_area[players_in_area.keys()[0]]
|
||||||
|
hit_player.dead = true
|
||||||
|
hit = true
|
||||||
|
|
||||||
|
if has_node("%AttackTimer") and %AttackTimer.time_left > 0 and not hit: return
|
||||||
|
if not subject.is_on_floor(): return %Fall
|
||||||
|
if input_direction.length() < 0.05: return %Idle
|
||||||
if has_node("%Walk") and %Input.walk: return %Walk
|
if has_node("%Walk") and %Input.walk: return %Walk
|
||||||
return
|
return %Run
|
||||||
|
|
||||||
|
func _on_attack_body_entered(body: Node3D) -> void:
|
||||||
|
if body == subject: return
|
||||||
|
if not "player" in body or not body.player: return
|
||||||
|
if body.dead: return
|
||||||
|
|
||||||
|
players_in_area[body.name] = body
|
||||||
|
|
||||||
|
func _on_attack_body_exited(body: Node3D) -> void:
|
||||||
|
players_in_area.erase(body.name)
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ func process_physics(delta: float) -> State:
|
|||||||
if not Main.is_server_or_predicting(subject.player_id, subject.client_prediction): return
|
if not Main.is_server_or_predicting(subject.player_id, subject.client_prediction): return
|
||||||
|
|
||||||
var input_direction = %Input.direction
|
var input_direction = %Input.direction
|
||||||
if input_direction.length() < 0.05: return %Idle
|
|
||||||
|
|
||||||
subject.apply_input_velocity(delta, input_direction, subject.run_speed, subject.acceleration)
|
subject.apply_input_velocity(delta, input_direction, subject.run_speed, subject.acceleration)
|
||||||
|
|
||||||
if has_node("%Walk") and %Input.walk: return %Walk
|
|
||||||
if not subject.is_on_floor(): return %Fall
|
if not subject.is_on_floor(): return %Fall
|
||||||
|
if has_node("%Dead") and subject.dead: return %Dead
|
||||||
|
if has_node("%Lunge") and %Input.primary_interact and (not has_node("%AttackCooldown") or %AttackCooldown.time_left == 0): return %Lunge
|
||||||
|
if input_direction.length() < 0.05: return %Idle
|
||||||
|
if has_node("%Walk") and %Input.walk: return %Walk
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ func process_physics(delta: float) -> State:
|
|||||||
if not Main.is_server_or_predicting(subject.player_id, subject.client_prediction): return
|
if not Main.is_server_or_predicting(subject.player_id, subject.client_prediction): return
|
||||||
|
|
||||||
var input_direction = %Input.direction
|
var input_direction = %Input.direction
|
||||||
if input_direction.length() < 0.05: return %Idle
|
|
||||||
|
|
||||||
subject.apply_input_velocity(delta, input_direction, subject.walk_speed, subject.acceleration)
|
subject.apply_input_velocity(delta, input_direction, subject.walk_speed, subject.acceleration)
|
||||||
|
|
||||||
if not %Input.walk: return %Run
|
|
||||||
if not subject.is_on_floor(): return %Fall
|
if not subject.is_on_floor(): return %Fall
|
||||||
|
if has_node("%Dead") and subject.dead: return %Dead
|
||||||
|
if has_node("%Lunge") and %Input.primary_interact and (not has_node("%AttackCooldown") or %AttackCooldown.time_left == 0): return %Lunge
|
||||||
|
if input_direction.length() < 0.05: return %Idle
|
||||||
|
if not %Input.walk: return %Run
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user