move to apply_input_velocity on the subject
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
extends State
|
||||
|
||||
func enter() -> void:
|
||||
subject.rotation_base.global_rotation.z = PI / 2
|
||||
|
||||
func exit() -> void:
|
||||
subject.rotation_base.global_rotation.z = 0
|
||||
|
||||
func process_physics(_delta: float) -> State:
|
||||
if not multiplayer.is_server(): return
|
||||
|
||||
return
|
||||
@@ -3,12 +3,9 @@ extends State
|
||||
func process_physics(delta: float) -> State:
|
||||
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()
|
||||
subject.apply_input_velocity(delta, Vector2.ZERO, 0.0, subject.air_deceleration)
|
||||
|
||||
if not subject.is_on_floor(): return
|
||||
if %Input.direction.length() < 0.05: return %Idle
|
||||
if %Input.walk: return %Walk
|
||||
if has_node("%Walk") and %Input.walk: return %Walk
|
||||
return %Run
|
||||
|
||||
@@ -3,14 +3,12 @@ extends State
|
||||
func process_physics(delta: float) -> State:
|
||||
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()
|
||||
subject.apply_input_velocity(delta, Vector2.ZERO, 0.0, subject.acceleration)
|
||||
|
||||
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
|
||||
|
||||
var input_direction = %Input.direction
|
||||
if input_direction.length() < 0.05: return
|
||||
|
||||
if has_node("%Walk") and %Input.walk: return %Walk
|
||||
return %Run
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
extends State
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
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
|
||||
|
||||
subject.apply_input_velocity(delta, input_direction, subject.run_speed, subject.acceleration if subject.is_on_floor() else subject.air_deceleration)
|
||||
|
||||
if has_node("%Walk") and %Input.walk: return %Walk
|
||||
return
|
||||
+2
-11
@@ -6,17 +6,8 @@ func process_physics(delta: float) -> State:
|
||||
var input_direction = %Input.direction
|
||||
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)
|
||||
subject.velocity = subject.velocity.move_toward(target_velocity, subject.acceleration * delta)
|
||||
subject.velocity += Main.gravity_velocity
|
||||
subject.move_and_slide()
|
||||
subject.apply_input_velocity(delta, input_direction, subject.run_speed, subject.acceleration)
|
||||
|
||||
if move_direction.length() >= 0.1:
|
||||
subject.last_direction = move_direction
|
||||
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.walk: return %Walk
|
||||
if has_node("%Walk") and %Input.walk: return %Walk
|
||||
if not subject.is_on_floor(): return %Fall
|
||||
return
|
||||
|
||||
@@ -4,6 +4,7 @@ extends Node
|
||||
var subject
|
||||
|
||||
func enter() -> void:
|
||||
print("Entering state: %s" % name)
|
||||
pass
|
||||
|
||||
func exit() -> void:
|
||||
|
||||
+1
-10
@@ -6,16 +6,7 @@ func process_physics(delta: float) -> State:
|
||||
var input_direction = %Input.direction
|
||||
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)
|
||||
subject.velocity = subject.velocity.move_toward(target_velocity, subject.acceleration * delta)
|
||||
subject.velocity += Main.gravity_velocity
|
||||
subject.move_and_slide()
|
||||
|
||||
if move_direction.length() >= 0.1:
|
||||
subject.last_direction = move_direction
|
||||
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)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user