How to make sweep work with rotation?

As noted in this bug report, sweep doesn’t work when using AddRelativeRotation, despite working just fine with AddRelativeLocation. (Just for the sake of clarity, I am using C++, rather than Blueprints, but I experience the same problem described in the bug report. I have of course set the sweep argument to true when calling these functions.) In my game, this bug leads to the player’s spaceship rotating through collision objects which are meant to block.

As of 16 April 2015 (i.e. over 6 months later), this bug doesn’t appear to have been fixed and no update has been given as to when this is likely to happen. It therefore looks likely that I will need to solve the problem in some other way.

As mentioned above, I need to prevent a spaceship rotating through collision objects which are meant to block. Does anyone have any suggestions/workarounds as to how this might be achieved?


Edit: Some additional information about my setup:

  1. The player’s ship is a custom pawn which has a static mesh component as its root component.

  2. The custom pawn’s constructor calls “SetActorEnableCollision(true);”

  3. The objects which the ship should be blocked by are static mesh actors which use a collision proxy made up of a number of convex hull collision meshes.

1 Like

Have you looked at the twinStickShooter c++ classes?

Hi DanaFo - thanks for replying!

I read through the TwinStickShooter C++ code and tried using similar code in my own project, but the ship is still able to rotate through the collision objects which are meant to block it. Even worse, I discovered that rotating a collision mesh into another collision mesh does not even register a collision hit, so I can’t even respond to it using bespoke code! :frowning: It seems as if collision detection is completely absent upon rotation…

Specifically, I tried all of the following, none of which made any difference:

  1. Calling “SetCollisionProfileName(UCollisionProfile::Pawn_ProfileName);” on the ship’s static mesh component.
  2. Using “RootComponent->MoveComponent(Movement, NewRotation, true, &Hit);” rather than AddActorLocalRotation().
  3. Adding code to respond to a hit by moving the ship away from the hit object in the case of a hit. As mentioned above, Unreal does not even register a hit when the collision occurs as a result of rotation rather than movement.

I’ve also attached a screenshot showing an example of the problem (with “show COLLISION” enabled in the console).


Hmm… it looks increasingly likely that this problem is impossible to fix until Epic fix various bugs re rotation of collision meshes. I just noticed this post which highlights a very similar problem. Hopefully it gets fixed soon - I’m just surprised Epic overlooked such a major bug as not having any collision detection on rotation. :-S

I’m also getting this rotation bug. In my case, I’m using AddActorLocalRotation with sweep, but my pawn is still penetrating through objects. When rotating back out of the wall, the pawn will actually pop out of the wall so there won’t be any penetration. It might have something to do with the angle of the rotation. Seems like there’s some sort of collision calculations occurring, but it just doesn’t work well. Have you figured out how to get around this?

Still nothing?

Have they added rotation sweep yet?

1 Like

Rotation sweep is still not supported in 4.21

May have to create your own solution.
If your pawn uses sphere collision then no rotation sweep is necessary since a sphere has no concave structures protruding from the main body.
If your pawn uses any other shape then maybe you could do something like adding an Overlap-Only component that rotates ahead of the colliding component by one predictive rotation amount per tick, and reports back if it overlapped anything before the real collider would have hit, and you can handle the same logic as if it was triggered by a Hit.

Found a workaround for it:
Set the tick or a ticking component to call the “Wake rigid body” function passing it the rotating mesh as the argument. Set the ticking interval accordingly to the desired precision of the workaround.

P.S. It should be Epic’s priority to fix this bug and not have it’s customers waste time finding ways to make their broken system work.

Didn’t work for me. Mind giving little more detail please?


1 Like

+1 Bump… Anyone know if using Set-Actor-Transform with its node SWEEP option enabled helps? Or is better in some versions of UE4 / UE5? Its such a strange bug. Workarounds are possible with physics movement / collision. But that’s not practical / workable for everything. :wink: