x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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:

alt text

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:

alt text

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:

alt text

Product Version: UE 4.12
Tags:
more ▼

asked Aug 19 '16 at 03:05 PM in Blueprint Scripting

avatar image

Boagz
50 14 21 28

avatar image ImVawx ♦♦ STAFF Aug 19 '16 at 03:20 PM

Hey Boagz,

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

In my Animation Blueprint:

alt text

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.

472557_ab.png (48.4 kB)
avatar image Boagz Aug 19 '16 at 03:34 PM

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?

avatar image ImVawx ♦♦ STAFF Aug 19 '16 at 03:44 PM

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)

avatar image Boagz Aug 19 '16 at 03:53 PM

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

alt text

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.

avatar image Alex.Bascom Aug 19 '16 at 03:47 PM

"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?

avatar image ImVawx ♦♦ STAFF Aug 19 '16 at 04:04 PM

Here are the Blueprint setups:

alt text

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

https://i.imgur.com/V0EEn4O.gifv

472557_bp_setup.png (230.5 kB)
avatar image Boagz Aug 19 '16 at 04:05 PM

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

alt text

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).

avatar image ImVawx ♦♦ STAFF Aug 19 '16 at 04:09 PM

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.

avatar image Boagz Aug 19 '16 at 04:38 PM

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?

avatar image ImVawx ♦♦ STAFF Aug 19 '16 at 04:56 PM

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?

avatar image Boagz Aug 19 '16 at 05:14 PM

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

alt text

But my player start is facing down the X:

alt text

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

avatar image ImVawx ♦♦ STAFF Aug 19 '16 at 05:35 PM

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

avatar image Boagz Aug 19 '16 at 06:06 PM

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:

alt text

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?

avatar image Boagz Aug 19 '16 at 06:10 PM

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:

alt text

Seems like a bug of some sort.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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.

more ▼

answered Aug 26 '16 at 01:08 PM

avatar image

ImVawx ♦♦ STAFF
6.8k 114 17 127

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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:

alt text

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.

122.png (326.3 kB)
more ▼

answered Jan 07 '18 at 07:09 PM

avatar image

shark3ds
1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question