← Pixel Dreamer Studio

Growing one cloud or aura zone grows all of them

Copies of a scene share the collision shape you set in the Inspector. Give each copy its own before you change its size.

A shape set on a CollisionShape3D in the Inspector is saved once in the scene, and every copy you place or instantiate() uses that same shape. Change shape.radius on one copy and every copy changes. In our Godot 4.7 test, growing one of three spore clouds from 1 m to 3 m grew all three, and each caught an enemy standing 2.5 m from its center. Give each copy its own shape with shape = shape.duplicate() in _ready(), or tick Local to Scene on the shape: then only the one grew.

The code

Put this on the Area3D root of your cloud, aura or circle scene, with a CollisionShape3D child that has a sphere, cylinder or capsule shape. Set radius from code whenever the zone should grow or shrink, or set grow_to and grow_time to have it grow by itself when it appears. radius 0 keeps the size the shape has in the scene.

extends Area3D
## A cloud, aura or circle zone that can grow or shrink on its own.
## Copies of a scene share the collision shape set in the Inspector, so changing
## the radius on one copy changes it on every copy. This script gives each copy
## its own shape when it enters the tree, then sets the radius you ask for.

@export var radius := 0.0:  # 0 = keep the radius the shape has in the scene
	set(value):
		radius = maxf(value, 0.0)
		_apply()
@export var grow_to := 0.0  # 0 = keep the size · higher = grow to this radius when it appears
@export var grow_time := 2.0  # seconds to reach grow_to

var _shape: CollisionShape3D


func _ready() -> void:
	for child in get_children():
		if child is CollisionShape3D and child.shape != null:
			_shape = child
			break
	if _shape == null:
		push_warning("cloud_zone: add a CollisionShape3D with a sphere, cylinder or capsule shape")
		return
	_shape.shape = _shape.shape.duplicate()  # this copy's own shape from now on
	if radius <= 0.0 and _shape.shape.get("radius") != null:
		radius = _shape.shape.get("radius")
	_apply()
	if grow_to > 0.0:
		create_tween().tween_property(self, "radius", grow_to, grow_time)


func _apply() -> void:
	if _shape == null or radius <= 0.0:
		return
	var s: Shape3D = _shape.shape
	if s is SphereShape3D or s is CylinderShape3D or s is CapsuleShape3D:
		s.set("radius", radius)
	else:
		push_warning("cloud_zone: radius works on sphere, cylinder and capsule shapes")

What we measured

A cloud scene, an Area3D with a 1 m sphere shape, saved as a .tscn and instanced three times, 10 m apart. Next to each one, 2.5 m from its center, a small enemy body. Each line gives how many enemies each copy caught after the change to the first copy. Two runs gave the same numbers.

Why it happens

A scene file stores each shape, material and other resource once. Every instance of the scene gets that same resource, which saves memory and is what you want while nothing changes it. Changing a property of the resource changes it for everyone holding it. duplicate() makes a copy that belongs to this instance only, and Local to Scene asks Godot to do that for every instance when it is created. Scaling the node also works, but it scales everything under the node with it, the cloud effect and any other shapes, and the shape still reports the old size.

What to change

The cloud itself: Nature & Druid VFX for Godot 4 has Spore Cloud in green and toxic, Spore Burst, Thorn Ring and Druid Circle in green and corrupt, and a PDVFX helper that spawns and scales an effect from code in one line, so the effect can grow with the zone.

Tested in Godot 4.7 with the Compatibility renderer.

Ready-made: Nature & Druid VFX for Godot 4 has 31 ready-made druid effects, including Entangle Roots, green and toxic Spore Clouds, Thorn Rings and healing flowers, 9 of them also in a PSX version.

More how-tos for Nature & Druid VFX for Godot 4: Scatter spikes, roots or trees in a circle without overlaps

More how-tos: Hazards, traps and attacks