Hi!
I’m brand new to Unity and want to create an Isometric turn-based game like Final Fantasy Tactics, Disgaea, etc. (at least a prototype to train myself).
The problem I’m facing here is that my camera follows my cursor on each of its movement as you can see here, while I would want the camera to start following the cursor only when it is at the edges of the screen.
I’m using an Isometric Z as Y grid with isometric tilemaps with it. I also have the cursor GameObject, which is the object I want to follow, moving with WASD.
Here are the components and parameters of my camera:
And here’s the CameraController script to follow the Cursor:
using UnityEngine;
public class CameraController : MonoBehaviour
{
public GameObject cursor;
private Vector3 offset;
private void Start()
{
offset = transform.position - cursor.transform.position;
}
void LateUpdate()
{
transform.position = cursor.transform.position + offset;
}
}
For this script, I followed the basic script found in the Unity documentation, but I tried a lot of different way to try and get the result I’m trying to achieve, which didn’t really worked well.
I also watched and read a lot of things about camera movement but still didn’t really understood everything, so I’m kind of lost on how I should approach this.
So could it be possible to somehow calculate or get the edges of what the camera sees to make it follow the cursor when it reaches them?