- Home /
Set Animator Parameter based on move direction?
Hey i am working on a twin stick top down game. left stick: move - left right up down. right stick: look in the direction the stick gets dragged
works all fine but now i wanna combine that with some animations. so when i drag the left stick to the left and the right stick up i want in the animator to be: Horizontal: -1 Vertical: 0 so i can play a walk sideward animation
but when i drag the left stick to the left and the right stick to the left too i want in the animator like: Horizontal: 0 Vertical: 1 so i can play a walk forward animation
how can i do that? here is my code so far for the movement:
var _camRel = _rightStickInput.y * mainCamera.transform.forward + _rightStickInput.x * mainCamera.transform.right;
var axisDirection = _camRel + transform.position;
_lookAtTarget = new Vector3(axisDirection.x, transform.position.y, axisDirection.z);
transform.LookAt(_lookAtTarget, transform.up);
var controlDirection = new Vector3(_leftStickInput.x, 0, _leftStickInput.y);
var actualDirection = mainCamera.transform.TransformDirection(controlDirection);
_animator.SetFloat("Horizontal", controlDirection.x);
_animator.SetFloat("Vertical", controlDirection.y);
Your answer
Follow this Question
Related Questions
How to link 2 animations of different objects in Mecanim? 0 Answers
Animation motion on base layer does not play after additional motion on second layer 0 Answers
Mecanim Animate Physics - When to use? 0 Answers
Changing speed of specific animation state, at runtime 1 Answer
Mecanim issue: Twitching when blending into blendtrees 1 Answer