Here is another great Cinema 4D Python Explosion Effector with User Data options.
Explosion Effector for Cinema 4D Motion Designers
The Explosion Effector is a powerful tool for motion designers working in Cinema 4D. This effector provides a dynamic and visually striking way to simulate explosions and chaotic movements for MoGraph objects, allowing you to bring energy and life to your animations. It’s perfect for creating dramatic effects like bursting particles, debris scattering, or any scene requiring controlled chaos.
How to Use:
- Add the Effector: Simply add the Explosion Effector to your MoGraph setup.
- Customize Parameters:
- Explosion Strength: Control the intensity of the explosion.
- Gravity: Adjust the pull of gravity on the objects.
- Chaos: Add randomness for a more organic look.
- Start Frame: Define when the explosion begins.
- Reset Simulation: Use the reset button to restart the effect instantly.
- Rotation Speed: Add rotational dynamics to the exploding elements.
- Fade Out: Enable fading to gracefully remove objects from the scene.
- Animate: Tweak the user data parameters to achieve the desired explosion effect and watch your MoGraph objects come to life.
- Iterate and Refine: Use the built-in randomness and user controls to experiment and refine the look of your explosion.
This effector is designed to integrate seamlessly into your workflow, giving you full creative control while saving time on complex simulations. Whether you’re creating cinematic moments or motion graphics for advertising, this tool empowers you to craft explosions that are as chaotic or controlled as you need.

"""
Explosion Effector with User Data
Required User Data Parameters:
1. Explosion Strength (Float, 1-1000, Default: 100)
2. Gravity (Float, -50 to 50, Default: 5)
3. Chaos (Float, 0-1, Default: 0.3)
4. Start Frame (Int, 0-1000, Default: 0)
5. Reset Simulation (Button)
6. Rotation Speed (Float, 0-10, Default: 1)
7. Fade Out (Bool, Default: False)
"""
import c4d
import math
import random
# Global storage for explosion system
explosion_system = {
"original_positions": [],
"velocities": [],
"rotations": [],
"start_times": [],
"initialized": False
}
def main() -> bool:
global explosion_system
# Get MoGraph data
data = c4d.modules.mograph.GeGetMoData(op)
if data is None:
return True
# Get current frame and count
frame = doc.GetTime().GetFrame(doc.GetFps())
matrices = data.GetArray(c4d.MODATA_MATRIX)
count = data.GetCount()
# Access user data parameters
explosion_strength = op[c4d.ID_USERDATA, 1] or 100.0
gravity = op[c4d.ID_USERDATA, 2] or 5.0
chaos = op[c4d.ID_USERDATA, 3] or 0.3
start_frame = op[c4d.ID_USERDATA, 4] or 0
rotation_speed = op[c4d.ID_USERDATA, 6] or 1.0
fade_out = op[c4d.ID_USERDATA, 7] or False
# Handle reset button
reset_simulation = False
button_state = op.GetDataInstance().GetContainer(c4d.ID_USERDATA).GetData(c4d.ID_USERDATA + 5)
if button_state and button_state.GetInt32(c4d.BITBUTTON_CLICKED):
reset_simulation = True
button_state.SetInt32(c4d.BITBUTTON_CLICKED, 0)
op.SetDirty(c4d.DIRTYFLAGS_DATA)
# Initialize or reset system
if not explosion_system["initialized"] or reset_simulation or len(explosion_system["original_positions"]) != count:
random.seed(int(frame)) # Seed for reproducible randomness
explosion_system["original_positions"] = [m.off for m in matrices]
explosion_system["velocities"] = []
explosion_system["rotations"] = []
explosion_system["start_times"] = []
for i in range(count):
# Random direction with chaos control
angle1 = random.uniform(0, math.pi * 2)
angle2 = random.uniform(-math.pi/2, math.pi/2) * chaos
power = random.uniform(0.8, 1.2) * explosion_strength
direction = c4d.Vector(
math.cos(angle1) * math.cos(angle2),
math.sin(angle2),
math.sin(angle1) * math.cos(angle2)
).GetNormalized()
explosion_system["velocities"].append(direction * power)
explosion_system["rotations"].append(c4d.Vector(
random.uniform(-1, 1),
random.uniform(-1, 1),
random.uniform(-1, 1)
) * rotation_speed)
explosion_system["start_times"].append(random.uniform(0, 10)) # Staggered start
explosion_system["initialized"] = True
try:
for i in range(count):
# Calculate time since explosion started
elapsed = max(0, frame - start_frame - explosion_system["start_times"][i])
if elapsed <= 0:
continue # Not exploded yet
# Apply physics
velocity = explosion_system["velocities"][i]
velocity.y -= gravity * 0.1 # Apply gravity
# Update position
matrices[i].off = explosion_system["original_positions"][i] + velocity * elapsed
# Apply rotation
rot = explosion_system["rotations"][i] * elapsed
rot_mx = (c4d.utils.MatrixRotX(rot.x) *
c4d.utils.MatrixRotY(rot.y) *
c4d.utils.MatrixRotZ(rot.z))
matrices[i] = matrices[i] * rot_mx
# Fade out if enabled
if fade_out and elapsed > 30:
fade = 1.0 - (elapsed - 30) / 100.0
if fade <= 0:
matrices[i].off = c4d.Vector(0, -10000, 0) # Move out of view
else:
matrices[i].v1 *= fade
matrices[i].v2 *= fade
matrices[i].v3 *= fade
except Exception as e:
print(f"Explosion Effector Error: {str(e)}")
explosion_system["initialized"] = False
return True
data.SetArray(c4d.MODATA_MATRIX, matrices, op[c4d.FIELDS].HasContent())
return True

