c# – How to correctly add animation for a rotating object with Script in unity?

I have the following structure of my Turret:
Turret -> Body -> Head
The Body rotates by Y and Head rotating by X via script to a moving target, I have created simple Idle animation for turret which rotate Body and Head to a left and right, up and bottom. I have created Animator with 2 States, 1 for my idle animation, 2th emty (In my perspective here should tower target Enemy), empty is default and connected to a idle with condition on bool variable. The problem when the Idle animation is added to an Animator, tower is stacked in static position.

The questions are:

  1. How to play animation in different rotations? (If object changes his Transform, and then play animation, the animation shout start not from 0,0,0 but from 90,0,0 for example)

  2. How to switch default behaviour of targeting Enemies, maybee I should add animation for a Targeting or smth like this?

I tried read manuals for an Animation rigging, and don’t understand should I use it or not.

Read more here: Source link