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.
radiusset to 3 on the first copy's shape: all three copies caught their enemy, and all three shapes read 3 m. The copies were holding the same shape.- The first copy's node scaled by 3: only the first caught its enemy. The shape itself stayed at 1 m and was still shared.
- Local to Scene ticked on the shape, then the radius set to 3 on the first copy: only the first.
- The script,
radius = 3on the first copy: only the first. - The script growing from 1 m to 3 m over 2 seconds: the enemy at 2.5 m was caught after 1.32 seconds, when the edge of the zone reached the edge of the enemy. A second copy growing at the same time grew to 3 m on its own.
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
grow_toandgrow_time: a cloud that spreads after a spore burst, or a ring that closes in.- The same thing happens to materials: changing one particle effect's color changes all of them.
- Hurting what stands inside: a damage zone. Slows that stack from several clouds: slow effects.
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
- Turn a 2D character left without the flicker
- A line or rectangle attack that hits what the player sees
- A scare that plays once, and only for the player
- An attack that hits even when a frame is slow
- A parry window that is the same length on every screen
- A pair of portals that sends you through once
- An expanding shockwave that hits each enemy once
- Explosion damage that walls block, on the frame it goes off
- A fire or poison zone that keeps hurting while you stand in it
- A spike trap that hits whoever is already standing on it
- Who is inside an AoE attack circle
- Block only attacks from the front
- A sword hitbox that hits each enemy once per swing
- Slows and roots that overlap
- Blink forward without going into or through walls
- Knockback that the walk code does not cancel
- Random spots spread evenly inside a circle
- Keep a pressure plate down while anything is still on it
- Refill the guard meter only after the hits stop
- Heal from the damage that actually landed
- Let the shield take what it can and pass the rest of the hit to health
- A saw blade that slides along its path at a steady speed
- Explosion damage that reaches big enemies
- A spinning laser that hits everything it sweeps over