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. Dismiss Notice

Animator.Play Changes Avatar Motion

Discussion in 'Scripting' started by aymenmir, Oct 7, 2020.

  1. aymenmir

    aymenmir

    Joined:
    Oct 7, 2020
    Posts:
    3
    Every time during the Update() function call, I call
    Code (CSharp):
    1. Animator.Play(clip_name, -1, time)
    . This is to ensure that the Update call is synced with the fbx animation file. Sometimes this works perfectly but at other times, the motion of the avatar changes completely. I don't change any parameters. Any help would be appreciated
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762
    If the Animator variable is an Animator, the Play() argument does not take a clip_name but rather a state_name.

    https://docs.unity3d.com/ScriptReference/Animator.Play.html

    Is that your issue? The clip is associated with a state in the animator, which COULD be named the same, but not necessarily.

    Also you might want to consider using properties to control how to state changes happen.
     
  3. aymenmir

    aymenmir

    Joined:
    Oct 7, 2020
    Posts:
    3
    Thanks. Even when I use the state name, the issue persists. The state name and clip name are same. I want to animate an avatar using an fbx file and store some parameters of the avatar. The number of calls to Update and the frames of the fbx file are not in sync. So I use animator.Play to start the clip at a time that synchronizes Update Calls and the fbx frames. If there is any other way to specify the start time of an animation clip, could you please let me know
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762
    I'm not sure you're supposed to be hammering on Play() that way, not even sure it behaves well if you do.

    Generally the entire point of animation is to fire it off and forget about it.

    I don't know what this even means or why this would even be important based on how I have used animations all my life.