despawn runner or chaser on disconnect
This commit is contained in:
+5
-13
@@ -1,22 +1,14 @@
|
||||
extends State
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
if not multiplayer.is_server() and (multiplayer.get_unique_id() != subject.player_id or not subject.client_prediction):
|
||||
return
|
||||
if not Main.is_server_or_predicting(subject.player_id, subject.client_prediction): return
|
||||
|
||||
var target_velocity = Vector3(0, subject.velocity.y, 0)
|
||||
subject.velocity = subject.velocity.move_toward(target_velocity, subject.air_deceleration * delta)
|
||||
subject.velocity += Main.gravity_velocity
|
||||
subject.move_and_slide()
|
||||
|
||||
if subject.is_on_floor():
|
||||
var input_direction = %Input.direction
|
||||
if input_direction.length() < 0.05:
|
||||
return %Idle
|
||||
|
||||
if %Input.walking:
|
||||
return %Walk
|
||||
|
||||
return %Run
|
||||
|
||||
return
|
||||
if not subject.is_on_floor(): return
|
||||
if %Input.direction.length() < 0.05: return %Idle
|
||||
if %Input.walk: return %Walk
|
||||
return %Run
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
extends State
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
if not multiplayer.is_server() and (multiplayer.get_unique_id() != subject.player_id or not subject.client_prediction):
|
||||
return
|
||||
if not Main.is_server_or_predicting(subject.player_id, subject.client_prediction): return
|
||||
|
||||
var target_velocity = Vector3(0, subject.velocity.y, 0)
|
||||
subject.velocity = subject.velocity.move_toward(target_velocity, subject.acceleration * delta)
|
||||
subject.velocity += Main.gravity_velocity
|
||||
subject.move_and_slide()
|
||||
|
||||
if not subject.is_on_floor():
|
||||
return %Fall
|
||||
if not subject.is_on_floor(): return %Fall
|
||||
|
||||
var input_direction = %Input.direction
|
||||
if input_direction.length() < 0.05:
|
||||
return
|
||||
if input_direction.length() < 0.05: return
|
||||
|
||||
return %Run
|
||||
|
||||
+4
-10
@@ -1,12 +1,10 @@
|
||||
extends State
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
if not multiplayer.is_server() and (multiplayer.get_unique_id() != subject.player_id or not subject.client_prediction):
|
||||
return
|
||||
if not Main.is_server_or_predicting(subject.player_id, subject.client_prediction): return
|
||||
|
||||
var input_direction = %Input.direction
|
||||
if input_direction.length() < 0.05:
|
||||
return %Idle
|
||||
if input_direction.length() < 0.05: return %Idle
|
||||
|
||||
var move_direction = Vector3(input_direction.x, 0, input_direction.y)
|
||||
var target_velocity = Vector3(move_direction.x * subject.run_speed, subject.velocity.y, move_direction.z * subject.run_speed)
|
||||
@@ -19,10 +17,6 @@ func process_physics(delta: float) -> State:
|
||||
var target_angle := Vector3.FORWARD.signed_angle_to(subject.last_direction, Vector3.UP)
|
||||
subject.skin.global_rotation.y = lerp_angle(subject.skin.rotation.y, target_angle, subject.rotation_speed * delta)
|
||||
|
||||
if %Input.walking:
|
||||
return %Walk
|
||||
|
||||
if not subject.is_on_floor():
|
||||
return %Fall
|
||||
|
||||
if %Input.walk: return %Walk
|
||||
if not subject.is_on_floor(): return %Fall
|
||||
return
|
||||
|
||||
@@ -9,42 +9,27 @@ func set_subject(new_subject: Node) -> void:
|
||||
state.subject = subject
|
||||
|
||||
func _change_state(new_state: State) -> void:
|
||||
if current_state:
|
||||
#print("Exiting: %s" % current_state.name)
|
||||
current_state.exit()
|
||||
if current_state: current_state.exit()
|
||||
|
||||
current_state = new_state
|
||||
#print("Entering: %s" % current_state.name)
|
||||
current_state.enter()
|
||||
|
||||
func process_physics(delta: float) -> void:
|
||||
if not current_state:
|
||||
return
|
||||
|
||||
if not current_state.subject:
|
||||
return
|
||||
if not current_state or not current_state.subject: return
|
||||
|
||||
var new_state = current_state.process_physics(delta)
|
||||
if new_state:
|
||||
_change_state(new_state)
|
||||
|
||||
func process_input(event: InputEvent) -> void:
|
||||
if not current_state:
|
||||
return
|
||||
|
||||
if not current_state.subject:
|
||||
return
|
||||
if not current_state or not current_state.subject: return
|
||||
|
||||
var new_state = current_state.process_input(event)
|
||||
if new_state:
|
||||
_change_state(new_state)
|
||||
|
||||
func process_frame(delta: float) -> void:
|
||||
if not current_state:
|
||||
return
|
||||
|
||||
if not current_state.subject:
|
||||
return
|
||||
if not current_state or not current_state.subject: return
|
||||
|
||||
var new_state = current_state.process_frame(delta)
|
||||
if new_state:
|
||||
|
||||
+4
-10
@@ -1,12 +1,10 @@
|
||||
extends State
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
if not multiplayer.is_server() and (multiplayer.get_unique_id() != subject.player_id or not subject.client_prediction):
|
||||
return
|
||||
if not Main.is_server_or_predicting(subject.player_id, subject.client_prediction): return
|
||||
|
||||
var input_direction = %Input.direction
|
||||
if input_direction.length() < 0.05:
|
||||
return %Idle
|
||||
if input_direction.length() < 0.05: return %Idle
|
||||
|
||||
var move_direction = Vector3(input_direction.x, 0, input_direction.y)
|
||||
var target_velocity = Vector3(move_direction.x * subject.walk_speed, subject.velocity.y, move_direction.z * subject.walk_speed)
|
||||
@@ -19,10 +17,6 @@ func process_physics(delta: float) -> State:
|
||||
var target_angle := Vector3.FORWARD.signed_angle_to(subject.last_direction, Vector3.UP)
|
||||
subject.skin.global_rotation.y = lerp_angle(subject.skin.rotation.y, target_angle, subject.rotation_speed * delta)
|
||||
|
||||
if not %Input.walking:
|
||||
return %Run
|
||||
|
||||
if not subject.is_on_floor():
|
||||
return %Fall
|
||||
|
||||
if not %Input.walk: return %Run
|
||||
if not subject.is_on_floor(): return %Fall
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user