Rotating a non-physics actor and blocking rotation in the case that it results in a collision

galact1c_
Sat, 18 Sep 2021 19:50:45 +0000
World Creation

TLDR: How do I rotate a primitive component with sweeping? The engine appears to not support it and I do not know how to approach the problem. Is physics really needed to rotate a box and have it detect collision?

I am working on a custom movement component for my networked game. This means that this movement component needs to support rewind and replay, and cannot use physics as it would be an overcomplication. This movement component is designed for a pawn which uses a box collider.

I am looking to find the best approach to rotate the box (primitive component) in my movement component, while also handling collisions that may occur.

UMovementComponent::SafeMoveUpdatedComponent and USceneComponent::SetWorldRotation accept a rotation and offer a sweep parameter, however:

SetWorldRotation accepts bSweep and OutHit as parameters, however, as stated in the documentation, bSweep is “currently not supported for rotation”

SafeMoveUpdatedComponent sets the rotation immediately, and it remains constant throughout the sweep. In other words, it only performs sweeping for linear movement. This means that if the rotation results in a collision, the pawn gets pushed away linearly from the wall. This works great, however, many collision issues arise once collisions occur with multiple surfaces. The problem is that if the pawn attempts to rotate where it does not have room (for example, in an extremely narrow corridor), then the pawn is pushed into one of the two surfaces. This renders applying rotational movement in SafeMoveUpdatedComponent not viable.

Ideally, for this movement component, rotation should be handled first, and applied if it can be pushed away from the surface it collides with. Otherwise, the rotation should not be applied. Only after rotation has been applied and collisions have been resolved, should linear movement be applied.

I’m unsure how to tackle this. Any suggestions are welcome!

1 post - 1 participant