I have this moon model. This moon model is divided into fragments.
See here:
I want it to explode and push these fragments out.
I have 2 issues.
Issue 1. Calculating the physics for pushing the fragments outward in an explosion would probably run very slow on most devices. Is there a way to pre-calculate these physics? Maybe rig all the parts with Motor6D and simulate it in blender?
I thought about using TweenService but I don’t know how fast that would be.
Issue 2. This explosion will happen in space, so I want the parts to slowly move in a constant direction (because there is no gravity).
Here’s some more info about the moon:
There are 98 total fragments
The texture is provided by a SurfaceAppearance object
There are three ways I believe you can do this, which would depend on some factors.
1.) Live ROBLOX physics
This one is the simplest and easiest to implement, all you must do is set the “Massless” property on all of those parts to “true” (a ticked box). You can then induce some sort of motion to them, whether that be through body velocity or a small explosion with a minimal force in the center.
2.) Animating
You can use a plugin like “Rig-Edit Lite” to make this an animatable “rig” inside your game, simply make the timeline as long as you can (either through “Moon Animator” or the default animation editor) and move the parts to the desired location, then create a new animation that is looping that will keep the parts where they are once the first animation is done playing.
3.) Tweenservice
Tweenservice is a little more complicated, but it should be easy to implement. just create a tween for each part or mesh, and move its CFrame over a designated time, you can make the part move to a specific location by getting the TargetCFrame to the parts CFrame (A goal you can call it.)
Again though this depends heavily on your use case, for example how far away will this object be? Is it always visible? What is your premise for this, what are you trying to accomplish, does it have to be going out indefinably?
Roblox Physics
The issue with using Roblox physics is that it will have gravity. Is there a way to make certain parts not be effected by gravity? Also as I said in the post the reason I don’t wanna do this is because it would be slow.
Animation
This is what I want to do. The issue is I don’t know how to take this rig and pre-calculate the physics. I could probably go into blender but the issue is I don’t know how to take a rig and make it animatable in blender. I also don’t know how to take that animation and put it back into Roblox.
Tween Service
Thought about this; but tween service would look kind of clunky. I’m looking for a cinematic type explosion.
Let’s start with 1, the unfavorable option.
If I am correct, almost all instances that are not a group or folder, something that is a physical object in game, has a massless property, you can check this box in the “Properties” tab to make them 0-Gravity!
Now with 2:
If it is already a rig, then you can simply animate it inside Roblox, no need to export it to blender! If it is not a rig, you can make it one by using the plugin “Rig-Edit Lite” to easily make one, unless you prefer doing it by hand.
Yes, I know I can rig it and animate it in Roblox. The issue is that I would have to manually animate each part. This would look horrid
The reason I mention blender is because blender has physics tools. The thing about that is I don’t know how to take those physics and put it into Roblox. Unless Roblox can calculate physics and put it into an animation
Well in that case if I remember blender may be able to convert your physics simulation into key frames, as expected this may take a while to render depending on your device specs.
If I remember, once the simulation is finished, or maybe before you run it, you can just bake it to an animation (Go to Object > Animation > Bake Action)!
Make sure to export it to the .FBX file format, as this is a format Roblox supports for animations on mesh rigs.
simple really, just anchor all of them… and here is the code put this in server sided:
local function Explode()
local CENTER_POSITION = Vector3.zero --the position of the moon as a whole
local _parts = {} --do something like moonParts:GetChildren()
local _part_to_dir = {}
for i, p:BasePart in _parts do
_part_to_dir[p] = (p.Position-CENTER_POSITION).Unit
end
local CONSTANT_SPEED = 10 --constant speed
local EXPLOSION_SPEED = 50 --burst speed at the start
local conn = game["Run Service"].Stepped:Connect(function(t,dt)
for p:BasePart, dir:Vector3 in pairs(_part_to_dir) do
p.Position += dir*(CONSTANT_SPEED+EXPLOSION_SPEED)*dt
end
EXPLOSION_SPEED *= 0.9 --play with this value, should be 0-1
end)
task.wait(10) --time for parts to continue going
conn:Disconnect()
end
This method would make it feel very robotic. I’m looking for something more cinematic. Something that you would get from a pre-calculated animation. Not a simple real-time calculation. Thank you though.
True, but some are more resource intensive than others. An animation is fairly cheap relative to real-time physics on all these parts. The main thing is, it would look way better. That is why I am going for that.
If it allows exporting via FBX, then do so!
If it is only OBJ, then you would in-fact need to export the parts individually or in a batch, then rig them in blender.
An easy teller of how you may be able to get the bones with it is if they are actual bone objects inside of the model rig, and not Motor6Ds
you can program this using TweenService.
You just need to get the direction from the center of the planet to the fragment and normalize the vector. And with linear interpolation, you can do this:
local TweenService = game:GetService("TweenService")
local AnimTime = TweenInfo.new(60)
local Planet = workspace:WaitForChild("Moon")
local PlanetFrags = Planet:GetChildren()
local PlanetCenter = Planet:GetPivot().Position
local function explode()
for _, frag: MeshPart in PlanetFrags do
local direction = (PlanetCenter - frag.Position).Unit
TweenService:Create(frag, AnimTime,{
Position = PlanetCenter + direction * 60}):Play()
end
end