Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    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:
    1,905
    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 ?