- Home /
Question by
PietroCarta · Nov 06, 2016 at 02:35 PM ·
animationmathvector
Animation direction
Hello everyone i have a twin stick game when the first stick drives the movements and the second stick drives the rotation.
i need somehow to drive the animations from movement and current player rotation
Vector3 newDirection = new Vector3(h, 0, v);
Quaternion rotationAwareDirection = Quaternion.FromToRotation(Vector3.up,
transform.rotation.eulerAngles);
newDirection = rotationAwareDirection*newDirection;
_anim.SetFloat("Horizontal", newDirection.x);
_anim.SetFloat("Vertical", newDirection.z);
i was trying something like this but with no luck
Comment
Best Answer
Answer by PietroCarta · Nov 06, 2016 at 02:52 PM
i was in the right direction. solved this way
Vector3 newDirection = new Vector3(h, 0, v);
newDirection = Quaternion.Euler(0, -transform.rotation.eulerAngles.y, 0) * newDirection;
_anim.SetFloat("Horizontal", newDirection.x);
_anim.SetFloat("Vertical", newDirection.z);
Your answer
Follow this Question
Related Questions
Animation Continue 0 Answers
Given a point, a "radius" and an arc, how do I find the resulting point? 1 Answer
Moveing on a Sphere in direction of Camera with Math 0 Answers
How to get the tangent and normal of a collision? 1 Answer
How can I calculate the Vector3 b using Vector 3 a pos with an angle? 1 Answer