Animator.Update C# (CSharp) Method

Update() public method

public Update ( ) : void
return void
    void Update()
    {
        Vector3 pos = new Vector3(
            Mathf.Lerp(xStartPosition, xEndPosition, (Time.time - startTime)*speed),
            transform.position.y, transform.position.z);
        transform.position = pos;
    }

Usage Example

    public static bool Play(Animator anim, string name, float speed = 1.0f, float time = 0.0f)
    {
        if (!anim)
        {
            return false;
        }

        // Enable animator
        if (!anim.enabled)
        {
            anim.enabled = true;
        }

        anim.speed = speed;
        anim.Play(name, -1, time);
        anim.Update(0.0f); // Update for the latest state

        return true;
    }
All Usage Examples Of Animator::Update