nahraná dosavadní verze hry
This commit is contained in:
19
3D blobici/Assets/Scripts/Player/CameraFollow.cs
Normal file
19
3D blobici/Assets/Scripts/Player/CameraFollow.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraFollow : MonoBehaviour
|
||||
{
|
||||
public Transform target; // The player's transform to follow
|
||||
public Vector3 offset = new Vector3(0f, 2f, -5f); // Offset from the target
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
// Update the camera's position to follow the target with an offset
|
||||
transform.position = target.position + offset;
|
||||
|
||||
// Make the camera look at the target
|
||||
transform.LookAt(target);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user