Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        signedOffset = offset;
        float tmpDamping = damping;

        if (move)
        {
            if (!move.GetFacingRight())
            {
                signedOffset.x = offset.x * -1;
            }
            if (!move.GetGrounded())
            {
                signedOffset.y = fallingOffsetY;
                tmpDamping     = fallingDamping;
            }
        }

        targetPosition     = Vector3.Lerp(transform.position, target.position + signedOffset, Time.time * cameraSpeed);
        transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref currentVelocity, tmpDamping);
        lastTargetPosition = target.position;
    }