Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Controlling a turret's idle animation (Animator) along with look towards target (script) together

Discussion in 'Animation' started by shaunimsorry, Jun 17, 2019.

  1. shaunimsorry

    shaunimsorry

    Joined:
    Jan 19, 2019
    Posts:
    11
    I've got a tank with a turret that rotates to where ever a ray cast collides with the terrain. Works fine but i wanted to create a 'scanning' / idle animation for it where the turret looks left and right when it doesn't have an enemy. Problem is when i put the animator on it stops the turret rotation script from working.

    Ive setup a few bools on this, one is an enemy near bool and also a hasMoveTarget bool

    i was wondering if there was a way i could only play this idle animation when a move target or no hostile is near ? Wanting help running both a script based 'animation' and an animator driven idle animation.

    Thank you
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,364
    I have similar, but I just procedurally use a sine or sawtooth formula and a clamp, to animate the idle search time.

    You could enable/disable your animator component when you acquire/lose your target.
     
  3. shaunimsorry

    shaunimsorry

    Joined:
    Jan 19, 2019
    Posts:
    11
    so i tried this, but the problem is the moment i put the animator on the turret SNAPS to the start point of the animation (looking about -65 left) so i think ill do this with code, wish there was a way to interpolate from its current state to the animator start pose...is there ?