DEG-81 카메라 컨트롤러
This commit is contained in:
parent
1cfeea2d4b
commit
1b70ad916e
8
Assets/PIH.meta
Normal file
8
Assets/PIH.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 214766d638d7daf41bb335b483002e18
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
29
Assets/PIH/CameraController.cs
Normal file
29
Assets/PIH/CameraController.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class CameraController : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Transform target;
|
||||||
|
public Vector3 offset = new Vector3(0f, 10f, -10f);
|
||||||
|
public float smoothSpeed = 5f;
|
||||||
|
|
||||||
|
public Vector2 minBoundary = new Vector2(-50f, -50f);
|
||||||
|
public Vector2 maxBoundary = new Vector2(50f, 50f);
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
// X축으로 55도 회전
|
||||||
|
transform.rotation = Quaternion.Euler(55f, 0f, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LateUpdate()
|
||||||
|
{
|
||||||
|
if (target == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Vector3 desiredPosition = target.position + offset;
|
||||||
|
desiredPosition.x = Mathf.Clamp(desiredPosition.x, minBoundary.x, maxBoundary.x);
|
||||||
|
desiredPosition.z = Mathf.Clamp(desiredPosition.z, minBoundary.y, maxBoundary.y);
|
||||||
|
|
||||||
|
transform.position = Vector3.Lerp(transform.position, desiredPosition, Time.deltaTime * smoothSpeed);
|
||||||
|
}
|
||||||
|
}
|
11
Assets/PIH/CameraController.cs.meta
Normal file
11
Assets/PIH/CameraController.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8b45463c9e39f224291703edb69fdbf0
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
x
Reference in New Issue
Block a user