Movement for character with complex collision shape

Hello.

Time ago i have seen other people asked for similar features, also as me - when i wanted to have a character not with a human body and not based on vehicle class. I am not sure this is still needed for someone, but i will post parts of solution i have used in some project. I have simplified it as much as possible.

Code link:
github.com/h2ogit/UE4-MultiCollisionMovement/

Description from github:

Movement for character with complex collision shape

Project example for UE 4.18

When you need to have a character with complex collision shape like a vehicle or a space ship or something similar - you will have character capsule size be too much bigger than needed. This will come to some restriction in movement of the character – character will not be able to come close to objects, move in narrow places and etc.

The next solution is not a complete solution but just a one of the ways and example and can be used as entry point you can start from. It was used for flying objects mainly, but it also support other physics modes but I think other additional code changes will be required additionally.

How to setup:

  1. Character MC should have one of the following settings enabled: bOrientRotationToMovement or bUseControllerDesiredRotation
  2. Change root collision size:
• For flying physics you can drop root capsule size to unit and disable root capsule collision at all.

• For walking physics root capsule size should be based on main walkable mesh
  1. You add MultiCollisionCapsuleComponent to cover the mesh shape and you build with this additional components complex shape of the character.

How it works:

  1. At character initialization movement component calls collect and update all MultiCollisionCapsuleComponent added to the character
  2. At movement phase instead of moving and checking root capsule component – movement component simulates movement with sweeps on all additional components and checks the most first hit and stops on it not allowing to move far than possible.
  3. The good move result is applied to root component as normal movement.
  4. Rotation is also physics based and happens after movement is finished, when character turns – all collisions are also tested and checked.

Optimization:

  1. Many additional components can drop FPS when you have many characters which are moving/colliding/sliding at same time. It is important to have the quantity of additional components as less as possible.
  2. Movement and Turning happens in different passes but it could be combined to one pass to decrease sweep checks. For example this could be done with next changes: Disabling PhysicsRotation function and enabling Character FaceRotation function which should calc new rotation for current frame. Then you need to override physics mode function so it will pass your new calculated rotation to movement code.

This system can be used with modular characters with some changes.

Very good, Very good,Very good,Very good,Very good,Very good。

Very good, Very powerful, Very powerful.

This look really useful, but I’m having a hard time getting this to work in 4.23. It tells me it needs to be recompiled, but when I try, it says “TestMultiCollision could not be compiled. Try building from source manually”
Is there a way to get this to work, or is there something similar that would work in 4.23?