I've tried using the cell fracture add-on but the boat looks all messed up. I tried hiding the cell fracture and then showing it when I wanted it to break but apparently I can't animate viewing on collections.
-
$\begingroup$ I encountered this with a star ship. I’ll get you the script, but basically what it did was adding drivers to all of the pieces’ visibility, and I think linking them to the main ship’s visibility. $\endgroup$– TheLabCatCommented Mar 1, 2022 at 6:12
-
$\begingroup$ @shrub: can you do it successfully with the default cube? if yes, pls try the same settings with your boat. If no, pls show us you settings of your cell fracture $\endgroup$– ChrisCommented Mar 1, 2022 at 6:45
-
$\begingroup$ You can use the collection as an instance and make the instance invisible then visible as explained here: youtube.com/watch?v=9WshXRndeOM ... As for the boat looking messed up it may have something to do with the rigid body setup? $\endgroup$– moonbootsCommented Mar 1, 2022 at 9:47
-
$\begingroup$ @Chris, it works perfectly on cube. $\endgroup$– shrubCommented Mar 1, 2022 at 10:48
-
$\begingroup$ @TheLabCat, sorry I'm quite new to blender, can u please explain what you mean. $\endgroup$– shrubCommented Mar 1, 2022 at 10:49
1 Answer
Here's some code to set up drivers on all the shattered pieces, to enable rigid body physics and show them in the render when a certain property of an empty (or any) object turns True.
Set up an empty named REF_OBJ and a variable accessed by DAT_PATH (in this case a custom property called "Explosion On") that turns True when the shattered pieces need to appear. Select all the shatter pieces in the viewport (but NOTHING else), and run this script. I recommend you also manually set up a driver the un-shattered boat to disappear based on the same REF_OBJ, DAT_PATH property.
import bpy
from bpy import data as D
from bpy import context as C
from mathutils import *
from math import *
REF_OBJ=bpy.data.objects["Explosion Point"]
DAT_PATH="[\"Explosion On\"]"
for o in bpy.context.selected_objects:
rd=o.driver_add("hide_render").driver
pd=o.driver_add("rigid_body.kinematic").driver
for d in (rd, pd):
v=d.variables.new()
v.targets[0].id=REF_OBJ
v.targets[0].data_path=DAT_PATH
rd.expression="not var"
pd.expression="not var"