public float turnSmoothTimeFire = 0.0001f;
float turnSmoothVelocity;
void Update()
{
float horizontal = Input.GetAxisRaw("Horizontal");
float vertical = Input.GetAxisRaw("Vertical");
Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;
if (Input.GetButton("Fire1"))
{
float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg + cam.eulerAngles.y;
float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTimeFire);
transform.rotation = Quaternion.Euler(0f, angle, 0f);
}
}
I have another if statement with the exact same setup (just the variables are called differently) for turning my player in the direction of moving, and i was wondering if i can prioritize my rotation. Currently, my player rather turns in the direction i am moving instead of the direction i am fireing, and i would like it the other way around. Help is greatly apprectiated.