Improved performance
This commit is contained in:
parent
afab83a35f
commit
885459f5d3
@ -11,6 +11,6 @@ var terrain: Terrain3D
|
||||
var instance_id: int
|
||||
|
||||
func _enter_tree():
|
||||
instance_id = OS.get_process_id() % 4
|
||||
instance_id = 0
|
||||
account = Account.new()
|
||||
account.name = "user%d" % instance_id
|
||||
|
@ -28,7 +28,6 @@ process_thread_group = 2
|
||||
process_thread_group_order = 0
|
||||
process_thread_messages = 0
|
||||
script = ExtResource("2_8hxcx")
|
||||
host = "akyoto.dev"
|
||||
|
||||
[node name="Ping" type="Node" parent="Client"]
|
||||
unique_name_in_owner = true
|
||||
@ -88,6 +87,7 @@ autostart = true
|
||||
[node name="Camera" parent="." instance=ExtResource("12_aljdh")]
|
||||
|
||||
[node name="World" parent="." instance=ExtResource("13_sqmhj")]
|
||||
process_thread_group = 2
|
||||
|
||||
[node name="Players" type="Node3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
@ -1,27 +1,30 @@
|
||||
class_name AnimationComponent
|
||||
extends Node
|
||||
|
||||
var player: AnimationPlayer
|
||||
var animations: AnimationPlayer
|
||||
var state: StateComponent
|
||||
|
||||
func _ready():
|
||||
state = owner.get_node("State")
|
||||
state.transitioned.connect(on_transition)
|
||||
player = $AnimationPlayer
|
||||
animations = %AnimationPlayer
|
||||
|
||||
func _process(delta):
|
||||
animations.advance(delta)
|
||||
|
||||
func on_transition(_from: StateComponent.State, to: StateComponent.State):
|
||||
match to:
|
||||
StateComponent.State.Idle:
|
||||
player.play("human/idle")
|
||||
animations.play("human/idle")
|
||||
StateComponent.State.Run:
|
||||
player.play("human/run-fast")
|
||||
animations.play("human/run-fast")
|
||||
StateComponent.State.Jump:
|
||||
player.play("human/jump")
|
||||
animations.play("human/jump")
|
||||
StateComponent.State.Fall:
|
||||
player.play("human/fall")
|
||||
animations.play("human/fall")
|
||||
StateComponent.State.None:
|
||||
player.play("human/RESET")
|
||||
animations.play("human/RESET")
|
||||
|
||||
func play(action_name: StringName, speed: float = 1.0):
|
||||
player.speed_scale = speed
|
||||
player.play(action_name)
|
||||
animations.speed_scale = speed
|
||||
animations.play(action_name)
|
@ -6,4 +6,6 @@
|
||||
script = ExtResource("1_lenw3")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
callback_mode_process = 2
|
||||
playback_default_blend_time = 0.2
|
||||
|
@ -19,6 +19,9 @@ func _unhandled_input(event: InputEvent):
|
||||
update_direction()
|
||||
update_actions(event)
|
||||
|
||||
if Input.is_key_pressed(KEY_P):
|
||||
get_tree().paused = !get_tree().paused
|
||||
|
||||
func update_direction():
|
||||
var move := Input.get_vector("move_left", "move_right", "move_forward", "move_backward")
|
||||
var direction := (Global.camera.global_basis * Vector3(move.x, 0, move.y))
|
||||
|
@ -14,6 +14,9 @@ func _ready():
|
||||
server_position = player.position
|
||||
|
||||
func _physics_process(delta: float):
|
||||
if absf(server_position.x - player.position.x) < 0.001 && absf(server_position.z - player.position.z) < 0.001:
|
||||
return
|
||||
|
||||
var time := interpolation_speed * delta
|
||||
player.position.x = Math.dampf(player.position.x, server_position.x, time)
|
||||
player.position.z = Math.dampf(player.position.z, server_position.z, time)
|
@ -14,6 +14,10 @@ var feet: Array[Foot] = []
|
||||
var ik_time: float
|
||||
|
||||
func _ready():
|
||||
if owner != Global.player:
|
||||
queue_free()
|
||||
return
|
||||
|
||||
for foot_name in feet_names:
|
||||
var foot = Foot.new()
|
||||
foot.bone_name = foot_name
|
||||
|
@ -3,5 +3,13 @@ extends Sprite3D
|
||||
|
||||
@export var health: HealthComponent
|
||||
|
||||
var sub_viewport: SubViewport
|
||||
|
||||
func _ready():
|
||||
texture = $SubViewport.get_texture()
|
||||
sub_viewport = %SubViewport
|
||||
texture = sub_viewport.get_texture()
|
||||
health.value_changed.connect(on_health_changed)
|
||||
|
||||
func on_health_changed():
|
||||
sub_viewport.render_target_clear_mode = SubViewport.CLEAR_MODE_ONCE
|
||||
sub_viewport.render_target_update_mode = SubViewport.UPDATE_ONCE
|
@ -14,9 +14,12 @@ region_rect = Rect2(0, 0, 84, 26)
|
||||
script = ExtResource("1_vynft")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="."]
|
||||
unique_name_in_owner = true
|
||||
disable_3d = true
|
||||
transparent_bg = true
|
||||
size = Vector2i(200, 26)
|
||||
render_target_clear_mode = 2
|
||||
render_target_update_mode = 1
|
||||
|
||||
[node name="HealthBar" type="TextureProgressBar" parent="SubViewport"]
|
||||
anchors_preset = 15
|
||||
|
@ -29,6 +29,9 @@ func _physics_process(delta):
|
||||
if !body.is_on_floor():
|
||||
body.velocity.y -= gravity * delta
|
||||
|
||||
if !body.velocity:
|
||||
return
|
||||
|
||||
body.move_and_slide()
|
||||
|
||||
func on_direction_changed(new_direction: Vector3):
|
||||
|
@ -12,6 +12,9 @@ func _ready():
|
||||
(owner as Character).controlled.connect(on_controlled)
|
||||
|
||||
func _process(delta):
|
||||
if absf(angle_difference(root.rotation.y, angle)) < 0.001:
|
||||
return
|
||||
|
||||
root.rotation.y = Math.damp_angle(root.rotation.y, angle, rotation_speed * delta)
|
||||
|
||||
func on_controlled(controller: Controller):
|
||||
|
@ -4,4 +4,4 @@ func on_body_entered(body: Node3D):
|
||||
var health := body.get_node_or_null("Health") as HealthComponent
|
||||
|
||||
if health:
|
||||
health.take_damage(Hit.new(100))
|
||||
health.take_damage(Hit.new(50))
|
Loading…
x
Reference in New Issue
Block a user