generated from krampus/template-godot4
Emit gunk cubes from laser-gunk collision
This commit is contained in:
parent
965b3f6c12
commit
f425461a1e
5
.gitattributes
vendored
5
.gitattributes
vendored
@ -8,3 +8,8 @@
|
||||
*.wav filter=lfs diff=lfs merge=lfs -text
|
||||
*.ogg filter=lfs diff=lfs merge=lfs -text
|
||||
*.dds filter=lfs diff=lfs merge=lfs -text
|
||||
*.dylib filter=lfs diff=lfs merge=lfs -text
|
||||
*.so filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.dll filter=lfs diff=lfs merge=lfs -text
|
||||
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||
|
@ -39,6 +39,10 @@ gdscript/warnings/unsafe_method_access=2
|
||||
gdscript/warnings/unsafe_cast=1
|
||||
gdscript/warnings/unsafe_call_argument=2
|
||||
|
||||
[debug_draw_3d]
|
||||
|
||||
settings/addon_root_folder="res://addons/debug_draw_3d"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=1920
|
||||
|
@ -24,6 +24,8 @@ point_count = 2
|
||||
curve = SubResource("Curve_smx5b")
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_ykxlg"]
|
||||
emission_shape = 4
|
||||
emission_point_count = 5
|
||||
angle_min = -184.7
|
||||
angle_max = 239.3
|
||||
direction = Vector3(0, 0, -1)
|
||||
|
@ -5,8 +5,13 @@ const NORMAL_OFFSET = 0.05
|
||||
|
||||
@export var parent_tool: Spray
|
||||
|
||||
# Currently gunking
|
||||
var gunk_rid: RID
|
||||
var gunkable: Gunkable
|
||||
|
||||
@onready var laser_dust: GPUParticles3D = %LaserDust
|
||||
@onready var glow_light: OmniLight3D = %GlowLight
|
||||
@onready var gunk_dust: GunkDust = %GunkDust
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
@ -16,6 +21,29 @@ func _process(_delta: float) -> void:
|
||||
if c is Node3D:
|
||||
(c as Node3D).global_position = child_pos
|
||||
|
||||
var new_gunk_rid: RID = get_collider_rid()
|
||||
if new_gunk_rid != gunk_rid:
|
||||
gunk_rid = new_gunk_rid
|
||||
if gunkable:
|
||||
# Disconnect old signals to avoid emitting from previous node and accumulating connections
|
||||
if gunkable.painted_at_point.is_connected(gunk_dust._on_gunkable_painted_at_point):
|
||||
gunkable.painted_at_point.disconnect(gunk_dust._on_gunkable_painted_at_point)
|
||||
if gunkable.clear_total_updated.is_connected(
|
||||
gunk_dust._on_gunkable_clear_total_updated
|
||||
):
|
||||
gunkable.clear_total_updated.disconnect(
|
||||
gunk_dust._on_gunkable_clear_total_updated
|
||||
)
|
||||
gunkable = Gunkable.get_component(get_collider())
|
||||
if gunkable:
|
||||
# Connect signals of new gunkable to our gunk dust
|
||||
if !gunkable.painted_at_point.is_connected(gunk_dust._on_gunkable_painted_at_point):
|
||||
gunkable.painted_at_point.connect(gunk_dust._on_gunkable_painted_at_point)
|
||||
if !gunkable.clear_total_updated.is_connected(
|
||||
gunk_dust._on_gunkable_clear_total_updated
|
||||
):
|
||||
gunkable.clear_total_updated.connect(gunk_dust._on_gunkable_clear_total_updated)
|
||||
|
||||
laser_dust.emitting = true
|
||||
|
||||
glow_light.visible = true # TODO: tween maybe?
|
||||
|
@ -1,8 +1,10 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://b8vradbaw61ga"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://b8vradbaw61ga"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bqgi5p5nh6k1l" path="res://src/equipment/laser_cast/laser_cast.gd" id="1_xntcr"]
|
||||
[ext_resource type="PackedScene" uid="uid://oc6t5ubyybsa" path="res://src/effects/laser_dust.tscn" id="2_m5xmf"]
|
||||
[ext_resource type="Script" uid="uid://br7war1wh7wfd" path="res://src/equipment/laser_cast/flicker_light.gd" id="3_bkg64"]
|
||||
[ext_resource type="PackedScene" uid="uid://c3iv00vmdqxp0" path="res://src/effects/gunk_dust.tscn" id="4_ekmqg"]
|
||||
[ext_resource type="Script" uid="uid://b88k7m1mwrd0v" path="res://src/world/gunkable/gunk_dust.gd" id="5_r1geq"]
|
||||
|
||||
[node name="LaserCast" type="RayCast3D"]
|
||||
target_position = Vector3(0, 0, -2)
|
||||
@ -25,3 +27,8 @@ shadow_caster_mask = 4294967293
|
||||
omni_range = 1.0
|
||||
omni_attenuation = 0.7
|
||||
script = ExtResource("3_bkg64")
|
||||
|
||||
[node name="GunkDust" parent="." instance=ExtResource("4_ekmqg")]
|
||||
unique_name_in_owner = true
|
||||
emitting = false
|
||||
script = ExtResource("5_r1geq")
|
||||
|
@ -1,4 +1,4 @@
|
||||
extends GPUParticles3D
|
||||
class_name GunkDust extends GPUParticles3D
|
||||
|
||||
@export var emit_scale := 0.1
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://cdi5sl60mw1po"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://cdi5sl60mw1po"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://co0g2klfmor48" path="res://src/world/gunkable/gunkable.gd" id="1_47xoo"]
|
||||
[ext_resource type="Script" uid="uid://bom5qysgfvap1" path="res://src/world/gunkable/draw_controller.gd" id="2_srn13"]
|
||||
[ext_resource type="PackedScene" uid="uid://c3iv00vmdqxp0" path="res://src/effects/gunk_dust.tscn" id="3_vad3y"]
|
||||
[ext_resource type="Script" uid="uid://b88k7m1mwrd0v" path="res://src/world/gunkable/gunk_dust.gd" id="4_3mpo3"]
|
||||
|
||||
[sub_resource type="CapsuleMesh" id="CapsuleMesh_3mpo3"]
|
||||
radius = 0.1
|
||||
@ -53,8 +52,6 @@ top_level = true
|
||||
emitting = false
|
||||
amount = 64
|
||||
lifetime = 1.2
|
||||
script = ExtResource("4_3mpo3")
|
||||
emit_scale = 0.08
|
||||
|
||||
[node name="DebugMesh" type="MeshInstance3D" parent="GunkDust"]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user