added cap to number of rigidbody casings that can be in scene (or other particles)

This commit is contained in:
Derek
2024-07-21 14:19:28 -05:00
parent 4d736f2f70
commit 58cf16ec41
4 changed files with 16 additions and 4 deletions

View File

@@ -2,12 +2,18 @@ extends RigidBody3D
@onready var collision_shape = $CollisionShape3D
@onready var audio_drop = $DropSound
@onready var level_control = get_tree().get_current_scene()
var rng = RandomNumberGenerator.new()
var random_rotation = true
var particle_number
# Called when the node enters the scene tree for the first time.
func _ready():
#enter the scene and assign particle number
level_control.particle_number += 1
particle_number = level_control.particle_number
if random_rotation == true:
var lv_x = rng.randf_range(5.0,7.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)
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():
collision_shape.disabled = true
await get_tree().create_timer(1).timeout

File diff suppressed because one or more lines are too long

View File

@@ -8,7 +8,6 @@ var rot_amount : float
# Called when the node enters the scene tree for the first time.
func _ready():
minions = self.get_children()
print(minions)
# Called every frame. 'delta' is the elapsed time since the previous frame.

View File

@@ -4,6 +4,7 @@ extends Node3D
@export var player : Node
@export var money = 250
@export var health = 3
@export var MAX_PARTICLES = 100
@export var gun_1 : Resource
@export var gun_2 : Resource
var held_guns = []
@@ -11,6 +12,7 @@ var ammo_current = [0]
var ammo_reserve = [0]
var guns_dict = {}
var current_gun_index
var particle_number = 0
# Called when the node enters the scene tree for the first time.
func _ready():
@@ -32,7 +34,7 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
print(particle_number)
func gun_spawn(index):
#loop around if scrolling past available guns