I’m trying to make a game that is basically a Tekken clone, and I’ve spent three days on the camera. I have the movement and zooming in, but I can’t decide the direction it points in. I want to always be to side of the players, like this:
I’m to dumb to that though, I’ve tried at least 11 different solutions, and none of them work. If anyone knows what I’m doing wrong, could you help me fix it, maybe? Thanks
(
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraZoom : MonoBehaviour
{
public GameObject player1;
public GameObject player2;
public Vector3 offset;
private Vector3 pos;
public Transform test;
public float zoom;
private float comparison;
public float divDist;
public Vector3 center;
public void LateUpdate()
{
pos = 0.5f * (player1.transform.position + player2.transform.position);
float dist = Vector3.Distance(player1.transform.position, player2.transform.position);
divDist = dist / zoom;
test.position = pos;
transform.position = pos;
if(divDist < 0.5104699f)
{
divDist = 0.5104699f;
}
center = ((player2.transform.position - player1.transform.position) / 2.0f) + player1.transform.position;
transform.LookAt(center);
transform.position = (pos - offset * divDist);
}
}
)