Search Unity

Playing animation on prefabs works good at first, but then there's a delay...

Discussion in 'Animation' started by g-hoot, Mar 7, 2018.

  1. g-hoot

    g-hoot

    Joined:
    Apr 18, 2015
    Posts:
    69
    Hello all,
    I have 3 sliding doors. Have a user interface setup for each door with a button for "Open", "Close" and "stop' Am using the same animation for each one and controlling it with this code attached to each door and assigning the appropriate function to the corresponding button. When the program first starts, I can start all 3 doors opening, stop one, close the other etc just fine. After 15 seconds or so, then the response slows down. Like if I click open again on door number 2, and then immediately click open on number 3, it may be 10,20, 30 seconds before number 2 starts opening, then 3 may start right up, or may take a while too. Any ideas?



    using UnityEngine;
    public class ControlAnimation : MonoBehaviour
    {
    Animator animator;
    private void Awake()
    {
    animator = GetComponent<Animator>();
    animator.speed = 0f;
    }
    public void Open()
    {
    animator.SetFloat("speed", 1f);
    animator.speed = 0.5f;
    }
    public void Close()
    {
    animator.SetFloat("speed", -1f);
    animator.speed = 0.5f;
    }
    public void Stop()
    {
    animator.speed = 0f;
    }
    }
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,407
    Can you see what its doing in the Animator window?
    it should show which part is currently playing, so what its doing when the delay happens?
     
  3. g-hoot

    g-hoot

    Joined:
    Apr 18, 2015
    Posts:
    69
    Yes, I click through all 3 of them, and they are just sitting there doing nothing, then all of a sudden, one will start moving as it should.

    A little more info:
    I made the "slide" animation clip in the "Animation" window in Unity and then added an "Animator" component to the door. Created an animator controller for it and then added an idle animation clip and the slide clip to the controller. I set the transition time between them to "0".
     
  4. g-hoot

    g-hoot

    Joined:
    Apr 18, 2015
    Posts:
    69
    Also, I'm on Unity 2017.3.1f1
     
  5. g-hoot

    g-hoot

    Joined:
    Apr 18, 2015
    Posts:
    69
    Here's a video showing what's happening. I don't know how to increase the video quality uploading to youtube, so it's not a very good video, but you'll see at about 40 seconds in when I click to close Bin1, everything just sits there for about 30 seconds, then Bin1 starts closing.

     
  6. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,407
    i usually always remove all the blending from this settings, and disable exit times, have you tried that?
    upload_2018-3-9_11-37-9.png
     
  7. g-hoot

    g-hoot

    Joined:
    Apr 18, 2015
    Posts:
    69
    I deleted the idle state and transition completely, but it still does the same thing.
     
  8. ekergraphics

    ekergraphics

    Joined:
    Feb 22, 2017
    Posts:
    257
    I have the exact same issue.

    I just began using Animator for the first time, created a simple rotation animation, created a "No motion" state as the default, and also a "Direction" parameter. I then trigger my AnimationClip from script via Play, and each time I trigger it, some sort of delay gets added that increases exponentially. First animation is instant, second comes after a few seconds, and then it only takes longer for each subsequent trigger attempt.

    I'm using Unity 2017.2.0f3 and I could also show video of my setup if needed, but I can't share any files (note sure if I have time to set up an empty test project either right now, but we'll see in a few days maybe).

    Here's the animation controller, couldn't be simpler, I made no changes apart from the "Direction" parameter, I added no transitions:

     
    Last edited: Mar 20, 2018
  9. ekergraphics

    ekergraphics

    Joined:
    Feb 22, 2017
    Posts:
    257
  10. g-hoot

    g-hoot

    Joined:
    Apr 18, 2015
    Posts:
    69
    Have you sent this to Unity? I have a lot of proprietary models that my animations are attached to hidden under my red white and blue sliders, so I haven't taken time to clean it up to have something to send to them. Guess I'll do that soon. Maybe if you do too, they will be more likely to look into it.
     
    Last edited: Mar 26, 2018
  11. ekergraphics

    ekergraphics

    Joined:
    Feb 22, 2017
    Posts:
    257
    I have made a test project now which easily demonstrates this.

    How do I send it to Unity?
     
  12. g-hoot

    g-hoot

    Joined:
    Apr 18, 2015
    Posts:
    69
    Open the project in Unity and then got to "Help, report a bug". I made a small project to send them too, but the firewall here at work is blocking it and I can't sent it, so if you can send yours, please point them to this thread too if you don't mind.
     
  13. ekergraphics

    ekergraphics

    Joined:
    Feb 22, 2017
    Posts:
    257
    Done!

    Case 1018899
     
  14. g-hoot

    g-hoot

    Joined:
    Apr 18, 2015
    Posts:
    69
    Thanks!