added cap to number of rigidbody casings that can be in scene (or other particles)
This commit is contained in:
@@ -2,12 +2,18 @@ extends RigidBody3D
|
|||||||
|
|
||||||
@onready var collision_shape = $CollisionShape3D
|
@onready var collision_shape = $CollisionShape3D
|
||||||
@onready var audio_drop = $DropSound
|
@onready var audio_drop = $DropSound
|
||||||
|
@onready var level_control = get_tree().get_current_scene()
|
||||||
|
|
||||||
var rng = RandomNumberGenerator.new()
|
var rng = RandomNumberGenerator.new()
|
||||||
var random_rotation = true
|
var random_rotation = true
|
||||||
|
var particle_number
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
|
#enter the scene and assign particle number
|
||||||
|
level_control.particle_number += 1
|
||||||
|
particle_number = level_control.particle_number
|
||||||
|
|
||||||
if random_rotation == true:
|
if random_rotation == true:
|
||||||
var lv_x = rng.randf_range(5.0,7.0)
|
var lv_x = rng.randf_range(5.0,7.0)
|
||||||
var lv_y = rng.randf_range(0.0,3.0)
|
var lv_y = rng.randf_range(0.0,3.0)
|
||||||
@@ -20,6 +26,11 @@ func _ready():
|
|||||||
angular_velocity += transform.basis * Vector3(av_x,av_y,av_z)
|
angular_velocity += transform.basis * Vector3(av_x,av_y,av_z)
|
||||||
|
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
#once max particles reached delete from scene
|
||||||
|
if level_control.particle_number >= (particle_number + level_control.MAX_PARTICLES):
|
||||||
|
_on_timer_timeout()
|
||||||
|
|
||||||
func _on_timer_timeout():
|
func _on_timer_timeout():
|
||||||
collision_shape.disabled = true
|
collision_shape.disabled = true
|
||||||
await get_tree().create_timer(1).timeout
|
await get_tree().create_timer(1).timeout
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -8,7 +8,6 @@ var rot_amount : float
|
|||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
minions = self.get_children()
|
minions = self.get_children()
|
||||||
print(minions)
|
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ extends Node3D
|
|||||||
@export var player : Node
|
@export var player : Node
|
||||||
@export var money = 250
|
@export var money = 250
|
||||||
@export var health = 3
|
@export var health = 3
|
||||||
|
@export var MAX_PARTICLES = 100
|
||||||
@export var gun_1 : Resource
|
@export var gun_1 : Resource
|
||||||
@export var gun_2 : Resource
|
@export var gun_2 : Resource
|
||||||
var held_guns = []
|
var held_guns = []
|
||||||
@@ -11,6 +12,7 @@ var ammo_current = [0]
|
|||||||
var ammo_reserve = [0]
|
var ammo_reserve = [0]
|
||||||
var guns_dict = {}
|
var guns_dict = {}
|
||||||
var current_gun_index
|
var current_gun_index
|
||||||
|
var particle_number = 0
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
@@ -32,7 +34,7 @@ func _ready():
|
|||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
pass
|
print(particle_number)
|
||||||
|
|
||||||
func gun_spawn(index):
|
func gun_spawn(index):
|
||||||
#loop around if scrolling past available guns
|
#loop around if scrolling past available guns
|
||||||
|
|||||||
Reference in New Issue
Block a user