So I have a script for character movement. I have a script that forces the character to face the direction of movement. Problem is for my character, I need the rotation to be X: 90, Y, 180.
Here is my script. It works fine for what I want to do above, but it forces the X and Y rotation to 0. How do I fix this?
private GameObject parent;
private Vector3 dir;
void Start(){
parent = transform.parent.gameObject; //The object uses its parent's velocity
}
void Update () {
Vector2 dir = transform.parent.rigidbody2D.velocity;
float angle = Mathf.Atan2(-dir.y, -dir.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
}
}