Download

Move collision for mesh asset independently of visual Mesh?

I’m working on a movement component for vehicles, and for network replay / prediction - I need to be able to move the collision of the mesh independently of the visual mesh.

The issue here is that because of the variety of shapes with meshes - I can’t take a Character approach and use a simple collision shape for the collision. Instead I’m using mid-complex collision generated from the shape of the mesh. I’m hoping that I can offset the visual mesh from the collision for interpolation.

Anybody tried this, or had experience creating some kind of suitable component to handle the non-projectile collision?

For the tank’s roadwheels I’ve ended up using two components, one invisible for collision and visible mesh for rendering and animation of rotation. Visual mesh is attached to collision but still can be kinematic animated.

That’s essentially what I want to do. The trouble is in my case there are no wheels etc (hover vehicles), so i’ve got nothing else I can move independently of the mesh.

But you can use multiple components, can’t you?
At some point I’ve tried to use a single static mesh component just to do Sweep tests instead of raycheck for the wheels, there where bugs with Sweep results when scaled meshes where involved but overall this approach was working.

Anyway, my point is that you could load two static mesh/skeletal mesh components. The root one for physics and child one for visual, then on every tick you can have a full control over what your visual component is suppose to do, it doesn’t have to constantly follow your root component driven by physics. Something like this I’ve used for top down airplane game prototype, root component was a simple physics mesh used for some functionality and it would only pan and go up/down in the world without any rotation. Then to the root I just add a static mesh component for with visual representation of airplane and this mesh would do rolls and change pitch/yaw.

Maybe I’m just missing the point of what you want to achieve.

I could do that but the problem is I then pay double the cost to update the skeletal mesh (animation too) - since this is an RTS / FPS mix that’s quite a big overhead with a lot of vehicles in the world.

It would be easier / cheaper if I could update the visual mesh elements independently of the collision elements in the mesh component itself.

It should be possible with a bit of c++. There is a point where UE4 position of object/component is derived from the physics body (FBodyInstance ?), could be a good place to add your interpolation logic. I haven’t done this myself unfortunately and don’t have solid pointers on where to start.