I been struggling with this issue for 5 days now.
Searched the answers and still nothing concrete.
All I want is for my 3d character(Which is a ball) to look left and right.
But the rotation inputs get messed up somehow, making my character turn in weird unexpected ways and it's like I cant edit the rotation values to just go back and forth between two Y values. below is my code.
void Start()
{
rb2d = gameObject.GetComponent<Rigidbody2D>();
lookRight = transform.rotation;
lookLeft = lookRight * Quaternion.Euler(0, 180, 0);
}
void FixedUpdate()
{
grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround);
float move = Input.GetAxis("Horizontal");
rb2d.velocity = new Vector2(move * maxSpeed, rb2d.velocity.y);
if (move > 0 && !facingRight)
{
facingRight = !facingRight;
transform.rotation = lookRight;
Debug.Log("Transform: "+transform.localRotation.ToString());
}
else if (move < 0 && facingRight)
{
facingRight = !facingRight;
transform.rotation = lookLeft;
Debug.Log("Transform: "+transform.localRotation.ToString());
}
}
I really need some help here, because I feel this should not be so difficult to figure out.
If you need more info let me know, thanks.