You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			28 lines
		
	
	
		
			608 B
		
	
	
	
		
			GDScript
		
	
		
		
			
		
	
	
			28 lines
		
	
	
		
			608 B
		
	
	
	
		
			GDScript
		
	
| 
											2 years ago
										 | extends Node3D | ||
|  | class_name Particle | ||
|  | 
 | ||
|  | var life_time : float | ||
|  | var is_pause : bool = false | ||
|  | 
 | ||
|  | func _ready(): | ||
|  | 	for child in get_children(): | ||
|  | 		if child is GPUParticles3D: | ||
|  | 			var particle = child as GPUParticles3D | ||
|  | 			if particle.lifetime > life_time: | ||
|  | 				life_time = particle.lifetime | ||
|  | 			particle.restart() | ||
|  | 
 | ||
|  | func _process(delta): | ||
|  | 	if is_pause: | ||
|  | 		return | ||
|  | 	life_time -= delta | ||
|  | 	if life_time <= 0: | ||
|  | 		queue_free() | ||
|  | 
 | ||
|  | func set_pause(is_pause_set:bool): | ||
|  | 	is_pause = is_pause_set | ||
|  | 	for child in get_children(): | ||
|  | 		if child is GPUParticles3D: | ||
|  | 			var particle = child as GPUParticles3D | ||
|  | 			particle.speed_scale = 0 if is_pause else 1 |