How to turn avatar object programmatically without sending input to the animator?
This code is the part of tutorial, controlling avatar object.
1) I'm trying to disable the code that sends rotation input to the animator. 2) I want to control to turning "programmatically"
void FixedUpdate() {
float inputForward=0f;
float inputTurn=0f;
if (cinput.enabled)
{
inputForward = cinput.Forward;
inputTurn = cinput.Turn;
}
//switch turn around if going backwards
if(inputForward < 0f)
inputTurn = -inputTurn;
if (CharacterCommon.CheckGroundNear(this.transform.position, jumpableGroundNormalMaxAngle, 0.1f, 1f, out closeToJumpableGround))
isGrounded = true;
this.transform.Translate(Vector3.forward * cinput.Forward * Time.deltaTime * forwardMaxSpeed);
this.transform.Rotate(Vector3.up, cinput.Turn * Time.deltaTime * turnMaxSpeed);
rbody.MovePosition(rbody.position + this.transform.forward * inputForward * Time.deltaTime * forwardMaxSpeed);
rbody.MoveRotation(rbody.rotation * Quaternion.AngleAxis(inputTurn * Time.deltaTime * turnMaxSpeed, Vector3.up));
// anim.SetFloat("velx", inputTurn); <<--- Disable sending the rotation input to the animator.
anim.SetFloat("vely", inputForward);
anim.SetBool("isFalling", !isGrounded);
//clear for next OnCollisionStay() callback
isGrounded = false;
}
I was advised as not using turn animation is often better, but now I'm not sure this is better.. I don't see any big improvement and programmatically controlling the turn seems unachievable. Does anyone have idea how to implement this??? Thanks
Your answer
![](https://koobas.hobune.stream/wayback/20220612174312im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
how can i make drag and release (like billiard games) ball control 1 Answer
White/Yellow line under Third Person Character? 0 Answers
Why is my boat moving horizontal , when i scripted it for vertical ? 1 Answer
Air Control While Jumping? 1 Answer
Can anyone please tell what to do make a bomb explode on touching ? 1 Answer