Search Unity

Problem with Animator when building for webplayer

Discussion in 'Animation' started by trololo, Jul 22, 2014.

  1. trololo

    trololo

    Joined:
    Dec 13, 2012
    Posts:
    17
    Hi,
    I have a very random bug (I submitted an issue but no response from unity) which happen when i create a build for unity webplayer (i have a pro version and i use unity 4.5.2f1).
    Sometimes the animators looks like they are not loaded (my avatar stay in default position).

    This happen when i create the build (and not when i launch it), because when you notice that the bug happen, it always do. This is very annoying because i have four different animator in my game (i switch to one on another), and one of them is sometimes subject to the problem, but not always the same!
    I also use the unify script HeadLookController (which able to rotate a character head), but i don't think this is part of the current problem.
    Thanks for your help :)
     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Please PM me your bug number.
     
  3. SwenEG

    SwenEG

    Joined:
    Jul 23, 2014
    Posts:
    2
    Have you solved the problem?
    I seem to have a similar issue with the Animator and the Webplayer.
    I tried to load the Stealth demo from Unity and on some machine the Animator is not executing the shoot animation on others it does.
     
  4. tiagopasccoal

    tiagopasccoal

    Joined:
    Mar 26, 2013
    Posts:
    8
    Hi

    Have you solved the problem?
    I have a similiar problem, i have an animator for a charater with several animations, this works good on Windows, Mac, iOS and Android, but when i export to web same animations aren't playing.

    Thanks.
     
  5. SwenEG

    SwenEG

    Joined:
    Jul 23, 2014
    Posts:
    2
    No not really. What I did was change to Unity v4.3 which seems to work for me at least for PC.
    Now my animations run correctly on a PC in the web player, Mac is still not working properly.
     
  6. trololo

    trololo

    Joined:
    Dec 13, 2012
    Posts:
    17
    Well 3 months later, after rebuilding the bundles for my game, the problem is back again! I'm using Unity 4.5.4f1 and the problem only appears on web player (no problem on IOS and Android versions)...
     
  7. trololo

    trololo

    Joined:
    Dec 13, 2012
    Posts:
    17
    Animator.layerCount = 0 in that case...
     
  8. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Hi guys,

    So it seem like a bug we did fix for 5.0, the controller is never build by the build process. As a workaround copy paste this script inside a Editor Folder to get the option from the menu. Before you build your game make sure you click on Mecanim/Build controllers.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using UnityEditor;
    4. using UnityEditor.Callbacks;
    5.  
    6. public class MecanimUtility
    7. {
    8.     [MenuItem("Mecanim/Build Controllers")]
    9.     public static void DoBuildControllers()
    10.     {
    11.         UnityEditorInternal.AnimatorController[] controllers = UnityEngine.Object.FindObjectsOfTypeAll(typeof(UnityEditorInternal.AnimatorController)) as UnityEditorInternal.AnimatorController[];
    12.         Debug.Log("Building controller list ...");
    13.         foreach (UnityEditorInternal.AnimatorController controller in controllers)
    14.         {
    15.             Debug.Log("Building " + controller.name);
    16.  
    17.             string name = controller.name;
    18.  
    19.             // By changing a serialized property we are forcing the asset to rebuild itseft.
    20.             SerializedObject obj = new SerializedObject(controller);
    21.             SerializedProperty nameProp = obj.FindProperty("m_Name");
    22.             nameProp.stringValue = "temp";
    23.             obj.ApplyModifiedProperties();
    24.  
    25.             nameProp.stringValue = name;
    26.             obj.ApplyModifiedProperties();
    27.         }
    28.     }
    29. }
    30.  
    Let me know if it fix your issue
     
    Anx likes this.
  9. DINmatin

    DINmatin

    Joined:
    Aug 21, 2014
    Posts:
    14
    Ihave the same problem with animattios during buildtime for the web.
    running the above script gives me:
    Assets/MecanimUtility.cs(2,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?

    unity v 4.6.0b17

    thx, /martin.
     
  10. Anx

    Anx

    Joined:
    Jan 2, 2014
    Posts:
    6
    Works for me, thank you!
     
  11. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    @DINmatin, you need to put the script in an Editor folder, otherwise Unity will think that this script is part of your final game and UnityEditor namespace is not available in the player(standalone)
     
  12. DINmatin

    DINmatin

    Joined:
    Aug 21, 2014
    Posts:
    14
    thank you for caring mecanim.dev. i placed it in "C:\Program Files (x86)\Unity\Editor", my fault.

    for the others: create a folder in the projectfolder on the same level as Assets.
    works fine now. thx!
     
  13. laryk_ua

    laryk_ua

    Joined:
    Jul 26, 2014
    Posts:
    9
    I have a similar problem. One of my animators does not play an animations.
    Unfortunately, the script did not help.

    Is "Animator.layerCount = 0" an indicator of the problem?
    Possibly I have other problem, if layerCount = 1 for me.

    Thanks.
     
  14. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    yes, "Animator.layerCount = 0" is an indicator of the problem.

    In your case it probably something else.
    Please log a bug with your project so we can repro
    Thanx
     
  15. l1u2a3n4

    l1u2a3n4

    Joined:
    Jul 1, 2018
    Posts:
    1
    No meu unity 5 fica aparecendo esse erro :

    Erro CS0246: O tipo ou nome de espaço de nomes `animador 'não foi encontrado. Você está faltando uma referência de montagem?

    o que devo fazer ?

    usando System.Collections;
    using System.Collections.Generic;
    usando UnityEngine;

    classe pública PerssonagemWalk: MonoBehaviour {

    animador privado _animator;
    flutuador privado _run = 0;

    void Start () {
    animador = GetConponet <Animator> ();

    }


    void Update () {
    _Run = input.GetAxis ("vertical");
    Debug.Log (_Run);
    }

    }