Is there a way to lock the axis on a Pawn/Character BP?

Hi all, my main problem at the moment is I am making a pong style game to test my understanding within the engine. The ball currently fires with a set velocity and then keep the same velocity as it hits every paddle however it sometimes knocks the paddle backwards. I tried to set the actor location to the default Y axis using a bool to make it snap back to the correct location but it looks too jaunting.

I was hoping that there was a simple button like Unity where you could lock constraints on particular rotation and location axis so it could never move on the Y axis however I have been unable to find anything like that. I might just be missing something and if so a simple solution would be great, if not is there a way in blueprint to stop it from moving?

Thank you very much!

I was looking for this as well. Haven’t found anything yet.

So all you need to do to make this work is:

  • Attach a PhysicsConstraintComponent
  • Set Constraint Component 1 to be the name of the root component of your actor.
  • Leaving Constraint Component 2 empty will constrain the actor to the world
  • Lock/Free the particular axis set to get the plane you want. for example Free X,Y Lock Z will give you an actor that can move freely only on the xy plane and will not move up and down. Rotations work in revers Swing Angle 1 is Z, Swing Angle 2 is Y and Twist Angle is X. If XY is your 2d plane, then you want to set Swing Angle 1 to free, Swing Angle 2 and Twist to Locked.
1 Like

Worked great for me! :slight_smile:

On our 3D Side scroller game, we Constrained movement to the YZ axis, however, my character’s attacks are still able to throw the enemy along the x axis. How do I prevent this?

1 Like

I think you have “constrain to plane” option in Character Movement component

5 Likes

I was able to figure it out by using the “SetActorLocation”. You can set the number value of your locked axis, then connect the other 2 axes to “GetWorldLocation” of the same object.

Also don’t forget you can split the individual axis on those commands via right click and split.

The most clean way.

This is exactly what I needed to find and it worked perfectly. Was quite stumped and I am vey thankful. The bonus reply that is the most clean way was nice as well.

Didn’t work for me.

1 Like