Deformable Parts and Collisions

Hello all!

I’m working on an X4 game which I hope to be a mesh between Eve Online and Space Engineers (SE). Most of what both games do is now possible on the Roblox engine, but I’m finding it difficult to implement deformable ship parts like SE does. Now, to be fair Space Engineers uses a private in house engine called VRage (for Voxel Rage) which is built around deformable voxels. Ships in SE are voxel ‘grids’ with physics, making deformation much easier. I’d love to hear some of your thoughts on the best way to implement this in Roblox. I’ve split the problem into three major issues:

Collision Force
It is one thing to determine when parts collide, but it is a whole 'nother issue to determine the force at which parts collide! In my private tests I’ve found that

  1. the listener connection for the Velocity of baseparts doesn’t work
  2. checking the velocity delta between touch and touch ended doesn’t always work (sometimes the velocity changes the next tick?)
  3. checking the velocity delta between touch end touch ended can yield incorrect results if multiple parts hit at about the same time (the issue above complicates matters)
  4. checking the velocity can lead to incorrect results again because the change in velocity may be because of joints connected to other parts that slowed down, resulting in hitting a pebble while decelerating causing an entire wing to go boom

I’m really struggling with this issue, any of you have an idea to how calculate the collision force reliably?

Collision Location
Adding another player on complexity is deforming parts according to where it was hit. Unfortunately as far as I know the Roblox engine only tell us if parts are touching, not where they touch. The only solution I can think of to get where they collided on each other is including the custom collision detection I wrote a couple years ago (GitHub - idiomic/GJK-3D-Intersection). Is there a better way?

Part Deformation
I’m thinking that the best way to implement this is to destroy the original part and replace it with a similar model split into different parts and removing a couple closest to the collision location (the more force, the more removed). I’m envisioning a function much like the glass shattering scripts out there, but in 3D. Is this the best way, or how would you implement it?

Now I may not implement this feature until after the game is released, but I think these are issues worth discussing to explore what is possible on the Roblox engine. Thanks in advance for your responses!

6 Likes

Collision Force:
I would personally have some sort of internal script that tracks all active physics parts and their distance/time. As soon as it collides with an object, take an average of the last 3 calculations to get a reliable velocity.

Collision Location:
You could probably do something with raycasts or region3, maybe? Another super hacky solution would be to split the object into several parts which can detect collision individually - which should already be easy since you’re using voxels?

Part Deformation:
Split the (x) closest voxels into 9 parts and remove (y) closest to the collision; x and y varying on strength of collision.

1 Like

Raycasting could be useful when the area of impact is tiny, although I’m not sure if it’s a good solution.

I’m a little bit confused, because this isn’t really deformation, nor is it similar to what VRage does as far as I can tell. It sounds to me like you’re describing some sort of voxel destruction. Which is fine, because if you just want to make a good game, then realism doesn’t necessarily matter.

Either way, I’m not really sure what it is you want. If you want something like Space Engineers where the geometry of the voxels is subject to deformation, you’ve got your work cut out for you. On the other hand, voxel destruction is certainly capable of creating interactive and interesting gameplay.

It is not possible to physically use vertex deformation on any meshes at this time on Roblox.

I recall asking @zeuxcg about this at RDC US, the gist of what he said was “in the next few years”.

They do plan on adding it, it just won’t be happening soon.

2 Likes

Nobody said anything about deforming meshes :stuck_out_tongue: I’m sure someone interested enough could build something resembling a mesh out of WedgeParts with some custom physical properties. It’s certainly not advisable, but it’s still possible.

I assume zeuxcg was talking about deformable body physics? If that’s the case, that’s really exciting. If not, I don’t really see the point.

I will take the time to think of a way to acheive a different approach to deformation.

Deformation is not easy at all in Roblox - However it is possible.

Deformation can be made easily with the right approach and the right tools provided by the engine itself, which can be quite limiting in some cases.

I can throw out a couple an idea that can suit your game. However this will require a bit of mathematical thinking in terms of this approach.

Do note that you can resize a MeshPart in any direction, where as a union you can only resize by the entire union itself. This is how you will be able to mimic the sense of deformation.

In your case, this is quite visually pleasing, but it can be performance heavy if you ever are thinking about making your game mobile/tablet compatible or targeting a wider range of PC users which their laptops are not quite up to date with the current generation of computing power. Not only this, but if you plan on making your parts have textures and so forth, you will have to also take into consideration where those will be places and how to deform them.

This is a quick method however judging from the idea that you are making an eve online style game (possibly including lots of players), you are going to have to optimize for that sense as well.

The idea I have includes your ship being separated as a mesh into separate MeshParts. I am not talking about splitting the mesh into something of the following: Hull, left_Wing, left_Engine, etc. What I mean is by splitting those meshes I have mentioned into approximately 2 depending on the object you are converting to a mesh. The overall goal is to use the MeshPart’s size property to mimic the idea of deformation. This will not only look decent but will be a cost effective method for your case, both for server and weaker performing clients. You can then use a bit of welding and math to take an estimate as to how that size property will change and how the mesh will be position/rotated.

Here is an example as to what I mean by resizing/position/rotation:

As you can see, the mesh part is able to mimic the sense of deformation in a jelly like manner due to some mathematical thinking. You can achieve the same on your ship models, however they won’t snap back like my jelly model does. Instead you can try to make the mesh part smaller and more squished for different mesh parts as objects or bullets hit them. As MeshParts have their own collision system similar to that of unions, you can modify the fidelity on them as well.

Here is a quick preview of an example I made using a plane using different meshes:

You can see the wings and engine are slightly deformed and rotated and the top of the tail (elevator) has also been poorly resized.

The only downside with what your system does is that you won’t be able to mimic bullet holes.

If you need me to further elaborate, don’t hesitate to ask any questions!

2 Likes

Real time CSG is only a couple weeks or months away. Depending on how well it works, OP could use that to deform his ships.

1 Like

How about using Beams?
On flat surfaces you could use multiple beams to represent the hull that can deform using Attachments.

I was going to use a similar method for the tires on my cars - as I’d like to simulate tire compression.

1 Like