I would like to see if a character is moving forward relative to it’s location in the world, and if it is then increase a variable.
Basically, if the ‘w’ key is pressed then increase the variable. The problem is, that I’m doing this in the event graph in my character’s animation blueprint.
Any way to do this simply?
Some more info:
I have a blendspace with 2 axis: x-speed and y-speed.
When the w key is pressed, I want to increase the x-speed,
and pressing the s key would do the opposite.
Same thing goes for y-speed, except d and a as appose to w and s respectively.
Changing these variables, in turn should change the animation it is playing…
I think what DJMidKnight is trying to say is that the Third Person Blueprint Tutorial does exactly what you are trying to do in their videos. Specifically, this one.
Edit:
That video I linked is the Blend Spaces one. He shows you how to get and assign the values for the blend space a few videos later but I recommend you start with the video I linked.
Yes I’ve followed them all. The problem is that in those there is only one variable which is speed. For mine I have 2, and they all go into the negatives. For the tutorial the guy just assign speed to the length of the vector your moving wether or not you’re moving forward left or right. For me I need to know if the chatter us moving forward or backward relative to himself.
Well, the way this usually works is you reference your Characters Animation Blueprint in your character blueprint and assign values there. You could use your characters CharacterMovementComponent Velocity value and get the X and Y movement out of that. Then you just pass it to the variable in your Animation Blueprint through the reference.
I can make images when I get home if you still don’t understand.
Sounds like you want to compare the result of GetActorForwardVector and CharacterMovement->GetVelocity. If the dot product of the velocity and the actor forward vector are greater than some threshold, you are moving forward.
For background, the dot product of two unit (normalized) vectors is equal to the cosine of the angle between them. So if they point exactly the same direction, the dot product equals 1, opposite -1, perpendicular 0. I would suggest testing within a tolerance, like if the dot product is > 0.7 (about 45 degrees), you are moving “forward” within 45 degrees or less.
I’m not sure what you mean by “how much”. The angle/dot product approach tells you how close you are to forward. You can also use the Velocity magnitude compared to the max speed, or a combination of that and the angle.