I’m trying to find out what direction a first person playable character is moving in and at what speed and an getting stumped with how to get this info from Velocity Vectores. Currently they output numbers in each world axis.
Does anyone know the best way of converting this data into both a direction the actor is in (not facing) and a speed at which they’re moving at?
Or is there a way of finding that information out already? I can’t find anyway other way of tracking this data.
[=;91901]
I’m trying to find out what direction a first person playable character is moving in and at what speed and an getting stumped with how to get this info from Velocity Vectores. Currently they output numbers in each world axis.
Does anyone know the best way of converting this data into both a direction the actor is in (not facing) and a speed at which they’re moving at?
Or is there a way of finding that information out already? I can’t find anyway other way of tracking this data.
[/]
That vector is the velocity and direction that the object is moving. Each value in the vector is the speed the object is moving in that direction.
I know, and what I’m after is the speed the player is moving in for for the current direction, rather than the speed of the X & Y axis individually. I’ve dug out Pythagoras Therum and have it the hard way and a tutorial is incoming but Epic, it would be great if we could access and change movement component settings via Blueprint.
[=;91901]
I’m trying to find out what direction a first person playable character is moving in and at what speed and an getting stumped with how to get this info from Velocity Vectores. Currently they output numbers in each world axis.
Does anyone know the best way of converting this data into both a direction the actor is in (not facing) and a speed at which they’re moving at?
Or is there a way of finding that information out already? I can’t find anyway other way of tracking this data.
[/]
The vector is the speed AND the direction. It gives you info on where you would end if you were at 0.0.0 and moved the distance/direction the vector gave you.
To get the direction only, use the normalize node. This changes the vector to a length of 1. This is the direction.
The velocity is the speed in each axis, which you then have to do further work on if you want the speed in the direction of movement.
Unfortunately there isn’t enough info in your comments about Normalize and Length for me to know what to do here. Are you able to provide a link to posts or tutorials on the subject?
And if anyone at Epic is out there, it would be great if you could put together some tutorials covering Character Movement and ways of accessing, understanding and manipulating the data available.
[=;91922]
I know, and what I’m after is the speed the player is moving in for for the current direction, rather than the speed of the X & Y axis individually. I’ve dug out Pythagoras Therum and have it the hard way and a tutorial is incoming but Epic, it would be great if we could access and change movement component settings via Blueprint.
[/]
Just get the length of the vector if you want the speed in that specific direction. There is a blueprint node for that, you input a vector and it gives you a float.
Then to get direction, just use the normalize node. It gives you a vector pointing in the direction the object is moving with length 1.
Have you tried getting the length of the “Get Forward Vector” node? This node is specifically designed to get the forward movement of the player character.
Have you tried getting the length of the “Get Forward Vector” node? This node is specifically designed to get the forward movement of the player character.
[/]
That’s not entirely correct… at least that’s not what it does.
Getting the forward vector only gives the forward vector of the actors rotation… no speed, just direction the vector has length of 1.
is correct, I had gotten my nodes mixed up! I decided to play around with this idea a bit and the image below is what I came up with. Note: While this works, I am sure there is a much more efficient solution out there.
This does work, and will test for positive and negative values, if you want to only test the forward movement speed you can change the != node to a > node, or add an abs node in front of the round nodes. I hope this helps you on your way, !
Note: As you can see, I have the abs nodes there, these were in the original setup but I wanted to make sure you could get negative values as well.
Thanks guys, I initially tried something along the line of what did but his version is much simplier. However, it wouldn’t give me an accurate reading if the player moved up and down slopes.
I’ve found that pumping the output of ‘Get Velocity’ into ‘Vector Length’ returns the current character speed perfectly. I then divide this by the Max speed to create a value between 0 & 1 that I can use for blends.
From Print Strings it looks to be accurate enough - it slightly creeps over the max speed value, which I put down to Floating Point errors, so I need to use absolute values to round things off.
However, it does bring up a couple of questions.
Firstly, speed is being referred to as ‘Velocity’ in Blueprints and ‘speed’ in the movement component options. Should that be unified?
And secondly, alot of the variables you set in movement components are maximum values. For each of those values, is it possible to get the current values with a single function, and if not, is it worth Epics adding functions or macros to simplify the process for users?
Hi ,
to get the direction of the player I would use the yaw rotation value which would be along the z axis so
**GetActorRotation—BreakRotation –>Yaw
**
to get your velocities in actor reference axis (local space) versus world reference axis, you should multiply your velocity vector by inversetransform direction
Here’s a blueprint proto
[INDENT][/INDENT] **InverseTransformDirection**
GetActorTransform ----> T ReturnValue is the velocity vector in local space GetVelocity ----> Direction