How to force a player character to face a certain direction?

Hello. I have an event that when triggered I want to change the player character to be in the exact same position as a reference skeletal mesh I have hidden in the scene.

I’m able to transform the player to the reference’s world position without a problem, but trying to force the player to rotate in the direction the ref is facing I cannot do. Even when I try to manually set the Rotation Z value to check if I can force the player character to face a particular direction upon event triggering it doesn’t happen.

Please can anyone help me outta this bc I feel it’s such a simple thing to do ahaha!
I included a pic of my blueprints for the event, tysm

If your pawn is using the player controller control orientation, you will likely want to change the control orientation of the player controller.

1 Like

Try to cast to your character bp and set it’s properties. Check your ref’s rotation value and character rotation value at runtime if they are matching. Also, check if that trigger runs when you want it to run. You can use print string for all of that checking. If you only want to set rotation and location as you mentioned, you don’t have to get references and their transforms. Just put the desired transforms in the node. Might need to use “set actor location(or offset)” and “set actor rotation” nodes, instead of “set actor location and rotation” node as single.

1 Like

Also you can run this transform sets inside of your character or pawn bp. Make a custom event and call it in trigger box begin overlap event by casting to your character. Casts are dynamic functions and only avaliable when they are referenced. Your character never be not existed and always referenced. So, casts will be fast and useful.

so instead of Get Player Character I’d use Get Player Controller?

I can’t find a set orientation node so I tried to rotate the player controller manually in a new node but when testing the direction the player faces upon triggering the event, the orientation remains the same:(

Thanks for your comprehensive answer! So would I cast to my character bp inside the trigger object bp? When I try this I can’t see how to set the rotation values of the player character.

I also wanted to use print strings for checking these values before but when I use the print string node after the event has finished I use Get String Attribute targeting the reference mesh, but the rotation values don’t seem to be an option?

I think using the ref transforms are better than the absolute ones in this case just to make it easier if I copy and paste this event again in the future. I also tried Using Set actor rotation / location nodes separately but get the same result:(

Something like this:

In the “Set Actor Location And Rotation” node, just put the desired location and rotation values. I’m trying to understand why you need “Ref Inside” actually.

okay, so I made a custom event inside the player character bp called testForceRotate which sets actor rotation.

I need to improve my understanding of casts though for example here, what would the object type be? This is inside the trigger box bp

Also, we don’t know the “Ref Inside” variable valid or not. If it’s not valid for your TriggerBP, It won’t get it’s location and rotation and change nothing.

hiya, sorry refInside is just a skeletal mesh I have hidden in scene to demo where I want the player to end up after triggering the event. so if I grab the transforms of refInside and apply them to the player they would be where I want to be.

In the example you gave above with the ‘Set Actor Location And Rotation’ node, I tried to just manually put the location and rotation values. The location works but again, the rotation doesn’t. The player continues looking in the same direction they were looking when they triggered the event, instead of being forced to look in the direction I want them to be in.

This works. I just realized that rotation transforms for pawns which has inputs to controls, won’t take the rotation. We learned together :slight_smile:

2 Likes

ty for your help that looks like it would work! my only question would be how to alter this so it would work inside the BP of the trigger event? So in the example below I’m inside the BP for a box that, on contact with the player, triggers the rotation event.

Now ‘Get Player Controller’ needs a target, what would I pass to the target? It doesn’t seem to give me a player index option like yours.

EDIT: nvm was using the wrong get player controller node, tysm for your help finally I rotated a player character lmao after transforming was so easy :sweat_smile:

“Get Player Controller” doesn’t need target normally. I looked for a “Get Player Controller” node with target and couldn’t find, where did you even get that tough :smile:

I guess “Set Control Rotation” node must be called in Player Controller BP. I’ll tell the steps:

  1. Create blueprint class inside of your Content Browser as “Player Controller”.
  2. Create another bp class as “Game Mode Base”.
  3. Open GameMode BP and select your own Player Controller BP:

  1. Open World Settings panel from Window menu if it’s closed:

  1. Select your GameMode BP as GameMode Override (you should see your custom PlayerController BP also shows in there):

  1. Create this function inside of your Player Controller

  1. Call the function from your Actor which has the Trigger Box:

These are the things I usually configure when I open new project. GameMode Override might be used like this or not, it is optional and can be changed via Project Settings (but this will be global for whole project and all maps until there is an override). Since you figured it out while I was writing a new Reply, this is just some additional information tough :smile:

1 Like

this is super helpful stuff ty I’ll look at using it going forward! I imagine it will help others if they come across the thread too.
I was using ‘get player controller’ from the player state menu accidentally haha

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.