Determine Actor direction in relation to the camera....

I’d like to know how to determine which direction my character is facing in relation to the camera in the 3rd person template…

I’d like to be able to push the Opposite direction my character is facing and have them do something different then if I push forward or to their sides…I got the reading the Right Axis portion correct (-1 to 1, easy enough) just not the rotation actor from camera rotation and how it’d relate to the Axis on the Gamepad…

I have a feeling this is easier than I’m making it…(in fact I have a poor version working but I’ve found some places it gets it wrong)…I figure I can be stubborn and drive around lost for another few hours or just pull over and ask for directions…Thanks

I’m not sure I understand the question 100%. But…

I believe there is a node to get you the “distance” between two different rotations. Maybe this would be useful to you?

Also, you can rotate a vector with a rotator… So let’s say you have a vector that is 100,0,0… and you rotate this with your cameras rotation… it could end up being 0,100,0 instead. Does it make sense? The node is called “Rotate Vector”. Maybe this can crack it open for you?

Also, you can “Get forward vector” on your rotations. So if you do this, you could get the difference between the rotations in degrees if you wanted. Start by getting the “dot product” of the two forward vectors, then get the “dcos”(degrees cosinus) of that number… The math is not straight in my head, so I might have given you wrong names for it. But it is a start I guess.

If you can explain better I can maybe have a look at it.

sorry I was way tired when I wrote that…still tired actually but it’s all for dodging in the direction the player is pushing and doing different animations due to that direction…Back dodges and side dodges…however I just couldn’t always get it to know which direction I was pushing compared to which direction the character was facing…it’s easy when I’m locked on cause the Player is always facing straight ahead then…

Dot product and rotate vectors…reminds me to check the content maps that come with the engine…I’ll look again into that and now that I’ve had some sleep try it all over again…

If I crack it I’ll put it up here…otherwise now that I’ve explained a bit more if there’s any further suggestions I’ll be on all day…until the Motion City Soundtrack concert tonight (hurray)…anyways…Thanks…

1 Like

figured out a way while trying to sleep…needless to say, I didn’t sleep…

Started with a macro to figure out which direction the Joystick is pointed…
4f5411d59c275deccd126d84b1eb8fd7a4ca71a2.jpeg

Then on to the part I was messing up…Actor rotation minus the camera rotation…a ton of compares later (every 45%) I can figure out which direction the Character is facing
0e6c0f242e3c7431c5267b2d49f9825c8d4ebfd8.jpeg

Lastly compare that to the direction they are tilting the joystick from earlier and we have which Dodge Animation to play compared to which direction the Character is facing
ea64184d24fab03ea5c8d929aa363aa245f325a9.jpeg

I feel like there Must be an easier (less messy) way to do this but damned if I know it…so this’ll do for now…
Thanks…

Here’s quick example of using dot product to get the angle between how two objects are facing each other. Replace the VehicleCube nodes with one for your camera and one for your player’s root.

Thank you…sooo much better…

Negate rotator a and combine with rotator b snd you have difference

Negate rotator and combine…lovely…
7c41b49f104eba9d898fe4d6d4ae32f3343daf76.jpeg

I was getting the numbers that go over 180 the other way…I don’t like that (although I just did the add/subtract 360 thing…still they’re ugly…Ha)…
much better and I was able to delete 2 compares this way…
Thanks…

you’re welcome

Doing directional dodges is actually MUCH simpler than you’re making it.

When dodge is pressed, first you get the direction of the input vector and normalize it. Then you “Rotate vector” by the Yaw of the control rotation (this same logic is used in the Third Person Template’s movement defaults to make pressing left always move you to screen left rather than world left). Then you take the Delta rot of the Actor rotation and the Control rotation (again, use a break-make pair to ONLY accept Yaw), get this rot’s forward vector and normalize it.

Then you use the dot product-inverse cosine (". aCosd") method above to get the angle between these two vectors.

This will tell you how many degrees of difference are between the stick direction (in camera rotation terms) and the actor rotation (in camera rotation terms). So if the camera is facing south, and you press left, and the actor is facing east (right of the screen), you should get an output value of 180.

You use this float to drive whatever blendspace or switch pin controls your directional dodge anims.

At least I’m pretty sure that works; you might need to flip around the position of the actor and control rotation nodes in the delta rot node, I’d have to try it to check.

Oh it has to be…Ha… not way this is as intended…still luckily it works which is a huge step forward although awesome if I get to take out some instructions to get the same result…

Speaking of which I gave it a go and it’s not quite giving a consistent result…
f85c589ea470da37919763bf1c771e4ec1a2b52b.jpeg
Getting different directions when I turn the camera around…likely something I did wrong…

For those who find this thread in the future and struggle like I have, I found out how to really do it! The posts above did not work for me, so maybe this will help those who feel the same way. I spent over 24 hours of work time figuring this out:

Tadaa! This is all that is needed. The float given out will produce the angle that the joystick needs to be in order to match the players current forward direction in the game. You can remove the absolute value, I just had that there leftover from testing.