예제 #1
0
    public void lookUpwards()
    {
        // since is allowed to look upwards and walk at the same time then make sure the correct
        // sprite anim is executed when is not walking
        if (lookingUp && !walk.isWalking())
        {
            lookUpAC.setupAndPlay();
        }
        // avoid re calculation if is already looking upwards
        if (lookingUp || !restoreLookUp.isRestored())
        {
            return;
        }

        // copy state
        tempConfig.setStateFrom(playerFollower);
        // apply changes
        playerFollower.lockY      = false;
        playerFollower.smoothLerp = true;         // the camera moves with nice lerping
        playerFollower.offsetY   += camDisplacement;
        playerFollower.timeFactor = speedFactor;

        restoreLookUp.setRestored(false);

        // set the correct sprite animation
        lookUpAC.setupAndPlay();
        lookingUp = true;
    }
예제 #2
0
 private void lookToDir()
 {
     // copy state
     tempConfig.setStateFrom(playerFollower);
     // apply changes
     playerFollower.lockY      = false;
     playerFollower.smoothLerp = true;         // moves the camera with nice lerping
     playerFollower.offsetY   += dirSign * camDisplacement;
     playerFollower.timeFactor = speedFactor;
     // set dirty state to the restoring logic
     restoreLookDir.setRestored(false);
 }
    public void init(float restoreSpeed)
    {
        tempConfig.setStateFrom(origFollower);

        // apply changes accordingly to expected effect
        origFollower.lockY      = false;
        origFollower.smoothLerp = true;         // nice lerping
        origFollower.timeFactor = restoreSpeed; // speedup the lerping

        enabled  = true;
        restored = false;
    }
    /**
     * LateUpdate is called after all Update functions have been called.
     * Dependant objects might have moved during Update.
     */
    void LateUpdate()
    {
        // difference between current cam's Y position and the final cam's Y position with offset
        float diff = Mathf.Abs(origFollower.getFinalDisplacement() - transform.position.y);

        // since the lerping function used with the camera is continued then it will take a little bit more to
        // reach the correct displacement from player. So let's use an epsilon value
        if (diff < 0.01f)
        {
            origFollower.setStateFrom(tempConfig);
            enabled  = false;
            restored = true;
        }
    }