From 45bc4c8a64c018fecaf8f8db9e1a133aef47c0dd Mon Sep 17 00:00:00 2001 From: Charles Heckroth Date: Sun, 18 Aug 2024 19:02:30 +0900 Subject: [PATCH] Add Fast Laser Effect Adds a new effect that hooks in to the physics system to make lasers go pewpew faser --- projectiles/fast_laser.tscn | 7 +++++++ units/player.gd | 5 ++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 projectiles/fast_laser.tscn diff --git a/projectiles/fast_laser.tscn b/projectiles/fast_laser.tscn new file mode 100644 index 0000000..95d660d --- /dev/null +++ b/projectiles/fast_laser.tscn @@ -0,0 +1,7 @@ +[gd_scene load_steps=2 format=3 uid="uid://dj6jn0ia62yba"] + +[ext_resource type="Script" path="res://projectiles/projectile_effect.gd" id="1_jlt11"] + +[node name="FastLaser" type="Node"] +script = ExtResource("1_jlt11") +speed_modifier = 3 diff --git a/units/player.gd b/units/player.gd index e704f29..d400c8e 100644 --- a/units/player.gd +++ b/units/player.gd @@ -9,14 +9,13 @@ const HORIZONTAL_BUFFER = 75 @export var Projectile : PackedScene @onready var projectile_spawner = $ProjectileSpawner -var FastLaserEffect : PackedScene = preload("res://projectiles/fast_laser.tscn") var DoubleLaserEffect : PackedScene = preload("res://projectiles/double_laser.tscn") var HugeLaserEffect : PackedScene = preload("res://projectiles/huge_laser.tscn") +var FastLaserEffect : PackedScene = preload("res://projectiles/fast_laser.tscn") # Called when the node enters the scene tree for the first time. func _ready(): Projectile = load("res://units/projectile.tscn") - _add_test_effects() func fire(): print('fired!') @@ -24,7 +23,7 @@ func fire(): # Effects must be instantiated for each projectile. # Finding a way to manage "which effects we need to instantiate" and # "Which effects are actually on this projectile" is key - var effects = [DoubleLaserEffect, HugeLaserEffect] + var effects = [DoubleLaserEffect, HugeLaserEffect, FastLaserEffect] p.spawn(owner, effects, transform) # Called every frame. 'delta' is the elapsed time since the previous frame.