MovementDirection.FixedUpdate C# (CSharp) Method

FixedUpdate() public method

public FixedUpdate ( ) : void
return void
    void FixedUpdate()
    {
        // detect last movement direction
        Vector3 direction = transform.position - lastOtherPosition;
        if (direction.sqrMagnitude > 0.01f)
        {
            if ( Vector3.Dot(direction, Vector3.right) > 0 )
            {
                lastDirection = MovementDirection.Direction.RIGHT;
            }
            else
            {
                lastDirection = MovementDirection.Direction.LEFT;
            }
        }

        positionChanged = false;
        // position changed?
        if ((lastOtherPosition - transform.position).sqrMagnitude > lastOtherSqrDistanceTreshold){
            updateOtherPosition();
            positionChanged = true;
        }

        // idle?
        if (Time.time - lastOtherPositionTime > lastOtherTimeout){
            notifyIdle();
        }
    }