본문 바로가기
개발/C#

유니티 C# 캐릭터 3인칭 카메라 따라가기 Follow Camera

by SPNK 2022. 12. 22.
반응형
  • 코드 작성
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FollowCamera : MonoBehaviour
{
    public GameObject target;

    public float offsetX = 0.0f;
    public float offsetY = 0.0f;
    public float offsetZ = 0.0f;

    Vector3 targetPos;


    void FixedUpdate()
    {
        targetPos = new Vector3(target.transform.position.x + offsetX,target.transform.position.y + offsetY,target.transform.position.z + offsetZ);

        transform.position = targetPos;
    }
}
반응형

댓글