i am trying to rotate a turret towards a target with two parts (the turret base which only rotates on the y axis, and the barrel only on the x axis) and with a rotation speed
problem is, i can’t get it to work independent of the parents rotation, if the turret is upside down or sideways on the wall it doesn’t work anymore (using localRotation makes it jitter/wiggle, idk)
my code (tried a few approaches tho, and none work):
(only the turretBase in this code)
Vector3 direction = target.position - transform.position;
direction.y = 0;
turretBase.rotation = Quaternion.RotateTowards(turretBase.rotation, Quaternion.LookRotation(direction), horizontalRotationSpeed * Time.deltaTime);