Search Unity

Animator functions not working

Discussion in 'Scripting' started by rennster200, Jul 20, 2019.

  1. rennster200

    rennster200

    Joined:
    Jun 21, 2019
    Posts:
    33
    Hello, I created a script where Pet is idle and if I leave his range he follows me...its working but animations are not....I tried with SetBool and with Set/reset trigger...none of that work...Idk why...I have that controller set with avatar and script on my pet...also have character controller..When I hit run I see animator editor and it works how it should be but animations not playing....The triggers are going between but nothing is playing...I triple checked the name of triggers and in the script
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class pet : MonoBehaviour
    5. {
    6.     static Animator anim;
    7.     public float speed;
    8.     public float range;
    9.     public Transform player;
    10.     public CharacterController controller;
    11.    
    12.     private object target;
    13.  
    14.     void Start()
    15.     {
    16.         anim = GetComponent<Animator>();
    17.        
    18.     }
    19.  
    20.  
    21.     void Update()
    22.     {
    23.         if (!inRange())
    24.         {
    25.            
    26.             chase();
    27.         }
    28.         else
    29.         {
    30.             transform.LookAt(player.transform);
    31.             anim.SetTrigger("isIdle");
    32.             anim.ResetTrigger("isWalking");
    33.             //anim.SetBool("isWalking", false);
    34.  
    35.         }
    36.     }
    37.  
    38.    
    39.  
    40.     bool inRange()
    41.     {
    42.        
    43.         return Vector3.Distance(transform.position, player.position) < range;
    44.  
    45.     }
    46.     void chase()
    47.     {
    48.  
    49.         //anim.SetBool("isIdle", false);
    50.  
    51.         anim.SetTrigger("isWalking");
    52.         anim.ResetTrigger("isIdle");
    53.         transform.LookAt(player.position);
    54.         controller.SimpleMove(transform.forward * speed);
    55.        
    56.     }
    57. }
     
  2. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    4,275
    - if you tick the trigger in the animator editor do the animations work?
    - do you have any error messages in the console?
     
  3. rennster200

    rennster200

    Joined:
    Jun 21, 2019
    Posts:
    33
    I will come home in 11 hours.. byt I think I only get 1 error something about assetsstore tool.dll but nit sure...
     
  4. rennster200

    rennster200

    Joined:
    Jun 21, 2019
    Posts:
    33
    If I tick the trigger its not playing... and only error I get is
    PrecompiledAssemblyException: Multiple precompiled assemblies with the same name AssetStoreTools.dll included for the current platform. Only one assembly with the same name is allowed per platform. Assembly path: {0}
    UnityEditor.Scripting.ScriptCompilation.EditorBuildRules.CreateTargetAssemblies (IEnumerable`1 customScriptAssemblies, IEnumerable`1 precompiledAssemblies) (at C:/buildslave/unity/build/Editor/Mono/Scripting/ScriptCompilation/EditorBuildRules.cs:221)
     
  5. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    4,275
    There you have it. You probably included the same asset twice. Somehow. First step is to remove one of them.
     
  6. rennster200

    rennster200

    Joined:
    Jun 21, 2019
    Posts:
    33
    oh ok
     
  7. rennster200

    rennster200

    Joined:
    Jun 21, 2019
    Posts:
    33
    still not working...
     
  8. rennster200

    rennster200

    Joined:
    Jun 21, 2019
    Posts:
    33
    In editor its showing its ticked but not playing