I’am at the moment prototyping a high down 3D sport in Unity 2021.3.4f1.
My character strikes with normal “WASD” and all the time faces in direction of my cursor’s location on the display screen. The digital camera is fastened and wont rotate with the character in any respect.
Merely described in beneath image:
My present resolution to roll on the appropriate angle is with a 2D freeform Cartesian animator mix tree, please see beneath hooked up SS on arrange and script to manage the Parameters: MoveX and MoveZ:
(Please disregard the * -1 within the GetAxis, its merely corrected for my character that is 180 levels rotated in sport)
Principally transferring character “up” with “W” and urgent roll bind with roll the character “up”. No downside to this point.
My subject with the offered resolution is when the character begins to rotate in direction of the cursor. GetAxis works in native coordinates described in beneath image:
As quickly as I rotate my character the coordination system rotates with it domestically:
This causes main points with my roll animation that makes use of root movement and principally sprint the character in its native coordinate system, however I need it to sprint in my world coordinates. Attempting to explain within the some what complicated image beneath:
This video is showcasing the difficulty in sport:
https://streamable.com/ko63c2
You’ll be able to clearly see in first rolls that the character rolls within the path that the character is transferring. When rotating 180 levels its precisely mirrored.
My first thought since Im not a to good coder is to do an enormous If/else assertion controlling my MoveX and MoveZ parameters when transferring with WASD. Or I substitute the Enter.GetAxis to get it in world coordinates (havent discovered any method to do that)…
What’s the easiest and most elegant method of reaching above outcomes?