Change player direction when running over an arrow

I have arrows on the ground and when a player runs over them, I want to change the players direction to move in the direction of the arrow.

I know this should be easy, but it is late and I don’t think my brain is working, so any direction is appreciated :slight_smile:

Hi,

I going from the assumption that you know how to detect the arrow (simple collision that fires an event).
So what I would do is when the arrow is detected you could set a variable in the PlayerState “bArrowRight” (example) and unset the other arrow variables.In the PlayerController you just need to change the method that manages the movement and check if a variable is to true and move it in the right direction.

rXp

Actually, you are right, I should be more clear on my intent.

I changed the arrow and used a Box Collision component instead. I rotated it so it is facing the direction I want to be going after colliding with it.

So if I run over the Box Collision component, I would like to have it rotate my character, and position it so I exit the Box Collision component centered over the X access (or whatever the red arrow protruding from the component is).

I can definitely start setting up the on component begin overlap, but I am not quite sure how to align the character with the collision box and smoothly change its course to the new course.

The character will more or less be entering at a 90 degree angle if that helps (it won’t be exact though).

Thanks for taking the time to answer!

Okey I see. If you created the arrow yourself I hope in the 3D editor you didn’t change the orientation of it.
Then know that forward is +Y in UE so you know if the Z rotation is at 0° then it means it is facing forward. From that value you can create a rotator and use it to rotate your character.

For example, if the arrow is at rotation Z = 25° you just need to get the 25, create a rotator with it (on the Z axis) rotate your character and move him forward.

Using the rotator is the rigt way to go, but it will jump from players current rotation to the desired rotation. You should use an RInterp To node to smoothly rotate the player over a small time period

Thank you both for the help, but I actually confused myself before posting. I was already actually making the 90 degree turn, the issue that I am running into is that I am coming out of the turn going to correct direction, but outside of the path I want to be in. I have three collision boxes, and depending on which one I overlap with, I want to center the player on the collision box and have them continue forward on the correct path.

Sorry for all of the confusion, It was really late when I posted that and I had been coding all day between work and then in UE!

Thanks for all of your help, I should be able to sort it out from here, but feel free to give me any suggestions, I am still at the phase where my BPs are rarely optimized :slight_smile:

I wish I could give you both credit for the answer, but I’ll give it to rXp as he does have the right answer to what I actually asked and answered my twice.

I hope you both have a good 4th :slight_smile: