I’ve created a Cube that I move using physics. I want the Cube to rotate only around the Z-axis during collisions, so I locked the rotations on the X and Y axes. However, I also want to have the ability to “manually” rotate it around the X and Y axes. Since I locked the X and Y rotations, AddTorqueInDegrees
doesn’t work.
I tried creating two StaticMesh components: one for managing physics (SM_P
, invisible to the player) and another for visualizing the actor (SM_V
). On every EventTick
, I updated the position and rotation of SM_V
to reflect the position and rotation of SM_P
. This allowed me to additionally rotate SM_V
on the X and Y axes manually.
Everything works really well, except that SM_V
has collisions turned off, which means that if I rotate SM_V
on the X or Y axis, it passes through other objects (because it has no collisions).
How can I solve this problem so that physics doesn’t rotate the object on the X and Y axes, but manual rotation is still possible? Is there a way to make SM_V
detect collisions and somehow “pass” those collisions to SM_P
?