How to prevent an actor to rotate / Lock rotation ?

Hello everybody !

I have a problem : I need a cube that can move when I push It but I want that it can’t rotate (no rotation on all axis) and that it can fall in a hole.

If someone has a solution to this … I tried many thing in the “Physics” part …

Thank you :slight_smile: !

Ha ha, interesting problem :slight_smile:

Let’s say that this box is an actor with box static mesh that can simulate physics. Then you can implement something in graph: use Tick event and call Set Actor Rotation with [0 0 0] rotator.

Hey :slight_smile: It is a solution and I’ve thinked about it before posting my question, as a temporary solution.

But I think that it is not an optimal solution because I have around 10 boxes so if I have to set the rotation at every moment … :p.

It must exist something more optimal.

Perhaps you could set up a trigger area surrounding the hole and nearby area that prevents rotate (aka set to 0,0,0) of the actor when it is overlapping. That would prevent using the undesirable tick function and let you use this mechanic on a per-hole basis (haha, now that’s a fun time term). You can filter the event by class, if you are concerned about other actors being affected.

Of course it’s not optimal. At least you can use this until someone post something better :slight_smile:
Btw. If you do this in C++ it wouldn’t be that bad :wink:

It would be great but I need that it can’t rotate at all on the entire map.

There is two problems :

  • When I push it, it rolls (so it rotate) and it is not what I want, I want it to slide on the floor, like when you push a box in the real world ^^. If I lock axis Z, it slides but it doesn’t fall anymore.

  • When I push it on the way for the hole, because there is a long way with some angles, sometime the box is blocked in the angles because it rotate a little …)

Well there you go then: when it gets pushed, it has some kind of overlap events right? Use that to set the no rotate, as well as the trigger area.

Sorry but I think that there is a misunderstood :

I have a box. I have a character.
When the character go in the direction of the box and touch it, I want that he push the box until he stop walking.
I need that the box slide and don’t rotate at all, so I need to have all the axis locked on rotation only.

I need it to be like that on the entire map.

If I use the “set rotation” 0,0,0 function, it doesn’t work not like I want because :

  • With the tick event the player stop to push and start again when I keep the forward arrow pushed.
  • With an overlap event, it will not work better.

Something else than “set rotation” must exist :).

But you speak about “set the no rotate” : if you know something to disable rotation on an actor or component, that’s what I need :).

Set up a large invisible box covering the area where the boxes will be, and make a blueprint based off of it. Plug this in and see if that does what you’re wanting.

Thank you for your help but It is not what I need :confused:

Because if the box overlap the area, it will happen only 1 time because the area is the whole map. So it will set the actor rotation of my box to 0,0,0 but it doesn’t prevent it to rotate after that.

The “set actor rotation” is not what I need …

A solution would be to lock axis Z and when it goes over a hole (and overlap a trigger box) unlock the axis Z, but I don’t find how to do that … there is no function to do that :confused:

There’s no way that there is nothing to lock the rotation but I’m not able to find it …

Of course! Dur, sorry lol

This event can go inside your box blueprint, and should fire off any time the actor is touched. That should include the ground.

Go into your components in the BP, go to collision, and check this box:

Simulation Generates Hits Events

End result should be that it’s always setting rotation to 0 if it’s being touched. For falling in the hole, you could use my other solution for a trigger area that’s only surrounding the hole.

Let me know if that doesn’t work either.

It does the same thing with the event tick and set actor rotation. Set actor rotation is not what I need here :). Because if I use it, the push animation is choppy / jerky. And it is very slow to push the box.

Hmm. Maybe you could rethink the mechanic altogether? It sounds like wanting only PART of its natural physics is problematic.

You could disable physics, but keep overlap events.

On overlap with the player, the box attaches to the player and moves with him.

On detach, give it a small impulse based on the direction it was being pushed on detach. You might have to reenable physics temporarily for the impulse. That’ll make it slide a bit.

You could alternatively write in a smooth translation from point A to point B on detach, simulating a slide.

For the holes, you will still need a trigger area. The trigger area would simply tell the box to translate to the center of the top of the hole, and then to the bottom of the hole.

So the mindset of simulating everything might be what you want, so you can have complete control over its physical elements.

On the physics module, drop down the constrains options and lock the rotation of all the axis you want.

64547-capture.png

2 Likes

mpo your a beast thank you i had a issue that i wanted lock rotation of a vehicle so the character can look around. iv tried everything else but your method works thank you so much

Looks like the behavior of a collision box that needs to be edited to the exact shape of the square.
Collision box too large, the box appears to float in space.
Collision box is actually a circle? Box is rolling and the corners are clipping into other objects.
True statement?

Also, if that box is falling off the edge and then rolling, there are multiple ways to solve that. Using a constraint would be rather sketchy but using an invisible box as a trigger to despawn the box that you are moving and then spawn the same box exactly where you would like for it to drop. Although they would have to line up fairly close to give the illusion of being the same box.
Set the box object as having no gravity until it collides with an invisible box opposite of the edge where it is rolling. Tricky technicality, definitely.

I have used a component attached to a spring arm to both lock or lag a components rotation of which is parented to the spring arm.

I love this solution, thanks for posting!

Nice! I’m using this for my VR character’s body! Works great!