From 1877acabed246f4f3712d65b7ba55d38527a6f3c Mon Sep 17 00:00:00 2001 From: Hecht Date: Sun, 30 Apr 2023 22:35:43 +0200 Subject: [PATCH] Fixed shader lag issue --- Fighter.gd | 8 +++----- Fighter.tscn | 33 +++++++++++++++++---------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Fighter.gd b/Fighter.gd index db098fd..d616572 100644 --- a/Fighter.gd +++ b/Fighter.gd @@ -18,7 +18,6 @@ var stamina:int = 100 @export var descriptor:String = "Foo" -var _material = null var _material_counter = 0 var _actions = [] @@ -42,8 +41,7 @@ func is_animation_done() -> bool: # Called when the node enters the scene tree for the first time. func _ready(): - _material = _animation_sprite.material; - _animation_sprite.material = null + _animation_sprite.material.set_shader_parameter("aura_width", 0) _animation_sprite.flip_h = orientation _animation_player.play("RESET") @@ -79,7 +77,7 @@ func _on_next_round(): _material_counter -= 1 if _material_counter == 0: - _animation_sprite.material = null + _animation_sprite.material.set_shader_parameter("aura_width", 0) func _schedule_next_action(): if _animation_player.is_playing(): @@ -108,7 +106,7 @@ func _on_animation_finished(anim_name): if (anim_name == "PowerUp"): _animation_sprite.frame = 0 - _animation_sprite.material = _material + _animation_sprite.material.set_shader_parameter("aura_width", 1) _material_counter = 3 func _on_animation_started(anim_name): diff --git a/Fighter.tscn b/Fighter.tscn index b0c7e16..2c131b1 100644 --- a/Fighter.tscn +++ b/Fighter.tscn @@ -6,8 +6,9 @@ [ext_resource type="PackedScene" uid="uid://blhw157wwm02k" path="res://DamageLabel.tscn" id="3_nllc3"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_r07wr"] +resource_local_to_scene = true shader = ExtResource("2_tgww4") -shader_parameter/aura_width = 1.0 +shader_parameter/aura_width = 0.0 shader_parameter/aura_color = Color(0.631373, 1, 0.827451, 1) [sub_resource type="Animation" id="Animation_uyuin"] @@ -138,6 +139,21 @@ tracks/0/keys = { "values": [34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50] } +[sub_resource type="Animation" id="Animation_u40bv"] +resource_name = "PowerUp" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), +"update": 1, +"values": [127, 128, 129, 130, 127, 128, 129, 130, 127, 128] +} + [sub_resource type="Animation" id="Animation_hs612"] length = 0.001 tracks/0/type = "value" @@ -200,21 +216,6 @@ tracks/0/keys = { "values": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24] } -[sub_resource type="Animation" id="Animation_u40bv"] -resource_name = "PowerUp" -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Sprite2D:frame") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9), -"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), -"update": 1, -"values": [127, 128, 129, 130, 127, 128, 129, 130, 127, 128] -} - [sub_resource type="AnimationLibrary" id="AnimationLibrary_jbrqc"] _data = { "Attack1.1": SubResource("Animation_uyuin"),