Constrain Movement on a Diagonal Axis

I’m hoping this is a pretty simple setting that I’m just missing somewhere.

I have an object that I have constrained to only Lateral movements (y-axis) but I want the constraint to rotate with the object when I adjust it in the scene.

For example, it is currently a long rectangle, and I want its movement to move along the long axis, if I rotate it, I want the axis to still be locked in that direction.

In-game all of the Rotation is Constrained, and the X axis is already constrained since it’s a 2-D game.

Physics Constraint is exactly what I needed! Literally just added the component to the child blueprint. Hardly needed to do anything. Great solution Thank you. Post it as an Answer and I will happily Accept it.

That’s a really nice question. Basically you want to constraint movement not to the world axis, but to the actor’s local axis.

I don’t think you can do that right out of the box, especially in blueprints, since BPs and constraints don’t really work together a lot.

The only solution I can think of as of now is maybe to create an invisible parent component and use a physics constraint to limit the movement to one local axis of the parent, but make the child rotation not dependent on the parent rotation, but vice versa, i.e. the parent replicates the child’s rotation.

Anyway, that’s just a thought, I don’t actually know if it’s possible to do something like that. I’ll have to check it a bit later.

P.S. Dear Epic, please add the possibility to lock Axis Loation and Rotation via Blueprints, that function is so much needed.

2 Likes

Hmm, alright, I’m glad I could be of help. Does that change the axis as you want it to? How do you rotate it?

Yes, I added the Physics Constraint component. In its details it asks for the names of two other components. I gave it the mesh I am manipulating, and the Empty Root. Then it allowed me to choose with axis (loc and rot) to constrain. (Limited, Free, or Locked). Once set up that way, it worked along its local axis without me needing to change anything additionally, I can just rotate it in the scene and the constraints rotate with it.

This works for me since I am manipulating the location of my mesh, as opposed to an actual actor. So I’m not sure if this would work with Actors on their own, but for my purposes It worked great.

Great! Actually, I have to thank you as well. Your question pushed me towards a solution I was struggling with for some time, and I finally found it. So thanks! =)