- Home /
Answer by Bunny83 · Oct 29, 2017 at 02:21 AM
What you want here is an exploded view. However there's not really a way to fully automate this for an arbitrary mesh / object and have the parts still nicely aligned.
However you can simply move the parts outwards from the centerpoint. Of course this will only work if your "parts" are actual seperate objects. If your model is a single mesh it's not possible as there's no information which "triangles" belong to the same object.
As pseudo code it would look something like:
foreach part
{
part.position = centerPoint + (part.originalPosition - centerPoint) * distance
}
So all you need is to store the original position of each part so you can update the current position this way. The "distance" value would determine how far the objects are apart. The normal value is "1" in which case the objects are in their original positions. If the distance is "0" all objects would collapse to the center point. If it's greater than 1 they will move outwards.
In the image it does not really look like they move directly away from the center point. Some parts move down, some up, some forward (in worldspace). This would require that each child object specify a direction, in world space, along which it's position is adjusted. similar formula:
part.position = part.originalPosition + (part.expandDirection * distance);
However, if one defines every single $$anonymous$$esh asset such that: the direction it "connects" to its parent-part is along... say... the LOCAL y-axis with the connection point at the LOCAL origin, then one can simply increase/decrease each mesh object's localPosition.y
to pull them apart/together.
Right, that's why i said:
there's not really a way to fully automate this for an arbitrary mesh / object and have the parts still nicely aligned
Specifying a seperate explosion direction for every part requires a lot work if you have many parts. Also most animated exploded views even expand in multiple steps. It's usually ment to show the order of assembly.
For example have a look at the air intake on the right side. It moved to the right in a straight line but the screws / rivets around expanded radially outwards from the moved intake. If you would combine both motions into a single direction and speed you would need a different direction and speed for every part. If you actually need different sequences you actually need to create a fulll grown animation like this one.
So my approach allows an automatic handling based on a center point. Of course you would get a better result to fine-tune the movement of every part.
I know it looked like a reply to you Bunny, but I was just trying to provide some more practical details for the OP, that I didn't think required a separate answer.
some other examples of how you usually create an exploded view in a CAD software.
https://www.youtube.com/watch?v=A0wYOtjGmE0
Your answer

Follow this Question
Related Questions
onmousedown on object teleport 1 Answer
Make an object mimic the rotation of another one according to their orientations 2 Answers
Movement on roads issue 1 Answer
Adding a transform component to an object which is not in the hierarchy 1 Answer
How do you access the transform component of an object in another class? 1 Answer