I’ve found this same problem in several other threads and answers but none of the solutions have worked for me.
The basic problem: I have a soldier character (pic 1) which, as far as I know, is properly rotated and rigged (rigging courtesy of Mixamo). My objective is, when it’s sphere collider-trigger encounters an enemy, it plays an animation and rotates so that the barrel of the rifle is pointed at said enemy.
When testing the animation, the rifle is pointed in the same direction as the base model’s z axis (pic 2), so rotating the base model to face the target should work, right?
But no. In Play mode, Animations work fine, but its orienting based on the z-axis of the root, not the model (pic 3).
function LateUpdate () {
if (enemy) {
var localTarget: Vector3 = transform.InverseTransformDirection(enemy.transform.position - transform.position);
var targetAngle = Mathf.Atan2(localTarget.x, localTarget.z) * Mathf.Rad2Deg;
var adjustedAngle = Mathf.Lerp(0, targetAngle, Time.deltaTime * SwivelSpeed);
transform.Rotate(Vector3.up, adjustedAngle);
}
}
function OnTriggerEnter (other : Collider) {
if (other.gameObject.tag == "EnemyInfantry") {
advance = false;
target = true;
unit.SetBool("Advance", advance);
unit.SetBool ("Enemy", target);
}
}
I’ve tried this with LateUpdate, FixedUpdate, altering the animation curves, checking and unchecking Apply Root Motion, checking and unchecking Write Defaults on the animations themselves… I can’t think of what else to try. Any thoughts?
Pic1:

Pic2:

Pic3:
