1

I have an animation of movement which consist of basic 2D multiple sprite. The animation is working correctly only in the editor but it is not showing in the build. After I run the build the animated object is created but I can't see it.

While I was searching I have found a popular Rotation problem(Quaterion etc) but since my animation is a basic 2D movement it doesn't apply here or does it?
(https://www.reddit.com/r/Unity3D/comments/425jmx/animations_work_in_editor_but_not_in_build/)

So any suggestions of what I am doing wrong here?

UPDATE:

added images of implementation

Build setting: build

AnimationClip:

animationclip

Animator:

animator

I've also tried recreating the Controller and Animator with no success

UPDATE

Adding prefabs to a script

adding prefabs to a script

Instantiating a game object:

   MazeZombie mazeZombiePrefab;
   MazeZombie mazeZombie = Instantiate(mazeZombiePrefab, mazeZombiePosition, Quaternion.identity) as MazeZombie;
    mazeZombie.transform.SetParent(transform);

MazeZombie class:

public class MazeZombie : MonoBehaviour
{
    void OnTriggerEnter2D()
    {
        transform.parent.SendMessage("OnZombieReached", SendMessageOptions.DontRequireReceiver);
    }

}

UPDATE

Platform: Windows 7 / Windows 10
Unity version: 2018.2.18f1

Ailixia
  • 11
  • 1
  • 5
  • Can you put more description about how you built the project? From the description you gave now, I'm guessing you forgot to add the `Scene` into the build. – ming060 Dec 10 '18 at 10:12
  • @ming060 I have updated the post. Scenes are loaded correctly – Ailixia Dec 10 '18 at 10:33
  • Is the sprite showing in the scene but without animation? – ming060 Dec 10 '18 at 12:02
  • @ming060 Yes, it is – Ailixia Dec 10 '18 at 13:34
  • In the Unity Editor, how do you play your animation? Is the animation playing by any trigger with script or it just keep looping itself? – ming060 Dec 10 '18 at 14:20
  • @ming060 Animation is always playing since I instantiate the gameObject – Ailixia Dec 10 '18 at 18:56
  • It sounds like the only difference is that running in Editor and Standalone version of your game. Maybe you can update some more scripts or information about your animation as clue. – ming060 Dec 10 '18 at 19:39
  • @ming060 I don't know what information can I add. I just have an animator an a prefab with animation controller on it. Animatoris always active and animation is always playing after the object is created. Simple as that. I've added some code, maybe this will help – Ailixia Dec 10 '18 at 19:50
  • I see. It's really simple. I have no idea now. Maybe I will try directly put the prefab into the scene without initiate it from script and see if it makes any difference. – ming060 Dec 10 '18 at 20:08
  • @ming060 I have a similar prefab called MazeRunner which is located on the Scene and it's animation is not displayd too. So that doesn't help much. Maybe you have some more ideas? – Ailixia Dec 10 '18 at 20:55
  • Maybe it's a bug of Unity build. If you can share part of your project including the prefab and animator/animation, I would like to try whether I can reproduce the problem in my environment. – ming060 Dec 10 '18 at 21:05
  • @ming060 If you will write me your email or sth like that I will send you a link on the project's Dropbox. I don't want the link to be public though. – Ailixia Dec 10 '18 at 23:09
  • Got it. I will try it on my Mac and Virtualbox Windows machine. Maybe you can update your environment (Platform and Unity version) to this post. If it is really a bug of Unity, those info may help. – ming060 Dec 10 '18 at 23:20
  • @ming060 I've tried building on Win7 and Win10. I've also tried substituting the animations with another multiple sprites elements and it's seems to work, but it doesn't help me to get the issue location. I think that another Prefab's components may be involved here – Ailixia Dec 10 '18 at 23:35
  • I tried to run the code in Editor and build. Running in the editor works fine. But when I built it and run, all the characters (player, zombie, coin) are all gone. And the shape and size of the maze is different from when I run it in editor at the same display resolution. I still try to figure out what's going on. – ming060 Dec 11 '18 at 21:06
  • @ming060 Yeah, the built is the main problem. You can change the size in Settings or settings.xml – Ailixia Dec 12 '18 at 01:50

1 Answers1

0

I had this problem and found I had checked the Static checkbox found on the object in the Inspector. It is located in the top right. Unchecking it fixed it.