如何让我的 y.axis 相机在跳跃时不上升?

问题描述 投票:0回答:0

我正在尝试开发一个 2D Plattformer,我不希望 y.axis 相机在跳跃时跟随。我的公共布尔称为“isJumping”。

using UnityEngine;

public class CameraFollow : MonoBehaviour
{
    public Transform target;
    public float smoothing = 5.0f;
    public float yOffset = 0.0f;

    private Vector3 offset;

    private void Start()
    {
        offset = transform.position - target.position;
    }

    private void FixedUpdate()
    {
        Vector3 targetCamPos = target.position + offset;      
        targetCamPos.y += yOffset;
        

        transform.position = Vector3.Lerp(transform.position, targetCamPos, smoothing * Time.deltaTime);
    }
}
c# unity-game-engine if-statement camera 2d
© www.soinside.com 2019 - 2024. All rights reserved.