Actor forward vector not working properly

I’m creating a 2d fighting game and I’m stuck on why I’m getting different values from different blueprints for my actor’s forward vector. When I print my actor’s forward vector from the actual character blueprint event graph I get what is expected, which is a positive forward vector in the x (+1.0) when facing my opponent on the left side and negative forward vector when turning to face my opponent from the right side (-1.0). However, when trying to grab that same forward vector and print the results from my animation blueprint which is attached to my character blueprint, I only ever get a positive forward vector value in the x (+1.0) and never a negative value when I turn to face my opponent from behind him (on the right side of him). I don’t know why I’m getting two different results for my forward vector every frame. Here is my Animation blueprint code:

Here is my 2d game with the output of the string shown on the left of the screen every frame. If you can’t read it is says x is +1.0 which is correct as my character is facing forward in the positive x direction:

However, when I’m on the other side facing in the negative x direction, the animation blueprint still outputs a +1.0 forward vector which is not correct:

Hey Boagz,

I have tried to setup the same scenario you have but I am not experiencing the same issue.

In my Animation Blueprint:

This will update to show, correctly, which way the character is facing, regardless of how the character is spawned in the world or how it is changed while playing.

Can you update your scene to only test one Character at a time and only log one result at a time? As in, only log from the Animation Blueprint or only log from the Character Blueprint.

Well in the above pictures that’s how my blueprint is setup. I’m only printing the log message from the animation blueprint and it’s only printing for my BP_Player (for which there is only one of in my game). I though maybe it was the mesh that was the problem but I’ve now imported three different meshes, including some of the ones from epic such as heroTPP, and still get this issue. This is maddening. Is there anything you can tell me in terms of how the forward vector is actually attached to a character? Or how getting the information on the forward vector would differ from animationBP to the characterBP? Also, was the engine you performed your test on 4.12?

GetActorForwardVector( ) is always going to get the rotation of the Root Component and use that to convert to a forward Vector.

Are you rotating just the Skeletal Mesh around and maybe not the Root Component (or the Actor itself)?

Also, if you were to create a new project with the Unreal Mannequin, do you see the same result? (not just import into your existing project)

“When I print my actor’s forward vector from the actual character blueprint event graph I get what is expected, which is a positive forward vector in the x (+1.0) when facing my opponent on the left side and negative forward vector when turning to face my opponent from the right side (-1.0).”

Can you show the actual blueprint graph of your character?

Trying to see if there may be some difference in the data you’re printing, for instance, if you’re only turning part of the character, such as the visuals?

Well here is how I’m rotating my character within my character blueprint:

Basically this “LockOn” function gets called when I press the lock on input action button. So if I’m behind my opponent and I press this button then my character will rotate, along the Z axis, to face my opponent. I’m not sure how SetActorRotation actually rotates my character (I’m assuming it will rotate the actual root component and not just my mesh) but I can tell you that when I print a log message for the forward vector following the call of this function in my Player blueprint I get the correct facing vector. So if I’m getting it there, then there is no reason I should get a different result in the animation blueprint (in my mind). Anyhow I will try and setup a lot of this game again in a new project, but that will take some time.

Here are the Blueprint setups:

Here is the print out from each (matching the colors of the comment boxes in text:

[Imgur][2]

Well here is my actual logic for calling the LockOn function I described above this post:

So I print the string after the lockon function get’s called and this outputs my correct forward vector rotation each frame (-1.0 when looking at opponent).

Can you run simply GetActorForwardVector in both the Animation Blueprint and the Character Blueprint and see if they match?

I want to make sure that the issue is the GetActorForwardVector node. If it is not, then I can look into helping you fix the other logic going on. If it is the GetActorForwardVector returning different values, then I can put a issue report for it.

Okay. Currently I can only turn my character around in game with the “lock on” input action button. So I need to be able to rotate my character around the z axis (Yaw) using just the right thumbstick of a controller. This will make it possible to test getActorForwardVector by itself without me having to call the LockOn function. Do you know a quick way to get this setup so I don’t have to go hunting for it?

You’ll have to setup input to be something other than your lock on event.

Here is the documentation for setting up character input and movement in Blueprint:

https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/CharacterMovement/Blueprints/Setup_2/index.html

Can you also make sure that your SkeletalMesh in the Character Blueprint is facing down X?

No, my skeletal mesh is currently facing down the Y in my character blueprint:

But my player start is facing down the X:

So when I start the game my player is facing the positive X direction.

Your SkeletalMesh looks right. It is the bottom left “world direction” that is what the player would be facing down, not the gizmo that selects the character.

Still test to see if simply using GetActorForwardVector in the Character Blueprint and the Animation Blueprint have different result.

Thanks

Okay, so I’m just rotating my character around and Logging out both the CharacterBP’s forward vector (Blue color) and the AnimationBP’s forward vector (Red Color). They are now both in sync:

So I’m not sure if it’s just the fact that I’m rotating my character with a button press in my lock function instead of with a thumbstick or mouse?

Also, interesting side note: When the animation blueprint is visible on my computer (on my second monitor) the blueprint prints out two forward vectors per frame. One showing the correct value and one showing every axis as 0:

Seems like a bug of some sort.

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will follow up.

I was with the same problem. For some reason the forward vector is not get the correct direction of the x axis. So i did it by other way.
I Was trying to get the forward vector of my FirePoint of my Barrel. I just put another Scene component at the Pivot:

So when the Turret Moves in the YAW Axis, all the child Scene Component of Barrel moves togheter and everthing is precisely telling me the start point (BarrelBase) and the end point (FirePoint) of my correct forward vector.

To generate the correctly Forward Vector just subtract BarrelBase from FirePoint. Just That.

I Try a lot of other solutions but only that solve my problem. If SomeOne has another Idea to solve it better, please it will be Welcome.

I know it is an old topic but there was no solution posted. Today I encoutered the same problem but got it solved.
The problem was, that one of the “Use Controller Rotation …” checkboxes on my character was checked accidentally and therefore no valid rotation was given in the Animation Blueprint.

1 Like

Thanks!

1 Like