Wrote method "create_tsunami"
This commit is contained in:
parent
ba48534c65
commit
fe4d719624
4 changed files with 65 additions and 3 deletions
|
|
@ -11,7 +11,7 @@ config_version=5
|
|||
[application]
|
||||
|
||||
config/name="The Dark Side of Earth"
|
||||
run/main_scene="uid://dpkr8yoobtej6"
|
||||
run/main_scene="uid://cxo6bq26huau7"
|
||||
config/features=PackedStringArray("4.5", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
|
|
|
|||
BIN
water/tsunami.res
Normal file
BIN
water/tsunami.res
Normal file
Binary file not shown.
|
|
@ -20,7 +20,7 @@ var radius : float:
|
|||
update_scale(mesh)
|
||||
mesh.material.set_shader_parameter("amplitude", amplitude)
|
||||
|
||||
var tsunami_size : float:
|
||||
@export var tsunami_size : float:
|
||||
set(new_size):
|
||||
tsunami_size = new_size
|
||||
var mesh = get_node_or_null("WaterMesh")
|
||||
|
|
@ -38,12 +38,16 @@ var tsunami_angle : float:
|
|||
update_scale(mesh)
|
||||
mesh.material.set_shader_parameter("tsunami_angle", tsunami_angle)
|
||||
|
||||
@export var animation_angle : float = 0
|
||||
@export var tsunami_base_angle : float
|
||||
|
||||
@export var rise_from : float = 2500;
|
||||
@export var rise_to : float = 3500;
|
||||
@export var rise_time : float = 120; # in seconds
|
||||
var auto_rise : bool = true;
|
||||
|
||||
@onready var start_unix_time : float = Time.get_unix_time_from_system()
|
||||
var direction = 1;
|
||||
|
||||
func update_scale(mesh):
|
||||
mesh.scale = 2 * (radius + amplitude * 2.1 + tsunami_size) * Vector2.ONE
|
||||
|
|
@ -57,6 +61,11 @@ func update_shader():
|
|||
func _ready() -> void:
|
||||
update_shader()
|
||||
radius = rise_from
|
||||
#auto_rise = false
|
||||
#radius = 2950;
|
||||
#create_tsunami(4.712, 1);
|
||||
#await get_tree().create_timer(10).timeout
|
||||
#create_tsunami(4.712, 1);
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
|
|
@ -68,3 +77,16 @@ func _process(_delta: float) -> void:
|
|||
water_reached_max_height.emit()
|
||||
else:
|
||||
radius = lerpf(rise_from, rise_to, (time - start_unix_time) / rise_time)
|
||||
|
||||
if $Tsunami.is_playing():
|
||||
tsunami_angle = tsunami_base_angle + animation_angle * direction;
|
||||
|
||||
# direction is -1 for left, +1 for right
|
||||
func create_tsunami(angle : float, dir : int):
|
||||
if direction not in [-1, 1]:
|
||||
push_error("direction must be in {-1, 1}")
|
||||
return
|
||||
direction = dir
|
||||
tsunami_base_angle = angle;
|
||||
|
||||
$Tsunami.play("tsunami")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://ca5ndobertnp4"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://ca5ndobertnp4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://chcxmo2uqvjbm" path="res://water/water.gd" id="1_m8een"]
|
||||
[ext_resource type="Shader" uid="uid://dg6cmhincvxua" path="res://water/water.gdshader" id="1_wjap7"]
|
||||
[ext_resource type="Animation" uid="uid://y1u85w0ew7uj" path="res://water/tsunami.res" id="3_6c1kg"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_m8een"]
|
||||
shader = ExtResource("1_wjap7")
|
||||
|
|
@ -13,9 +14,43 @@ shader_parameter/tsunami_angle = 0.0
|
|||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_6c1kg"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_6c1kg"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:tsunami_size")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:animation_angle")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_6c1kg"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_6c1kg"),
|
||||
&"tsunami": ExtResource("3_6c1kg")
|
||||
}
|
||||
|
||||
[node name="Water" type="Node2D"]
|
||||
script = ExtResource("1_m8een")
|
||||
amplitude = 20.0
|
||||
tsunami_base_angle = 4.712
|
||||
rise_from = 2400.0
|
||||
rise_to = 4200.0
|
||||
rise_time = 900.0
|
||||
|
|
@ -25,3 +60,8 @@ unique_name_in_owner = true
|
|||
material = SubResource("ShaderMaterial_m8een")
|
||||
scale = Vector2(10000, 10000)
|
||||
mesh = SubResource("QuadMesh_6c1kg")
|
||||
|
||||
[node name="Tsunami" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_6c1kg")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue