void Update() { Vector3 localCoordDiff = (cellCoordPosition.GetGlobalPos() - playerPosition.GetGlobalPos()) * cellCoordPosition.GetCellSize(); Vector3 localPosition = new Vector3(transform.position.x - localCoordDiff.x, transform.position.y - localCoordDiff.y, transform.position.z - localCoordDiff.z); cellCoordPosition.SetLocalPosition(localPosition.x, localPosition.y, localPosition.z); if (cellCoordPosition.OutOfCell()) { cellCoordPosition.UpdateGlobalPos(); cellCoordPosition.SnapCoordsBackToCell(); } }
public void SnapCamera() { cellCoordPosition.UpdateGlobalPos(); cellCoordPosition.SnapCoordsBackToCell(); transform.position = cellCoordPosition.GetLocalPos(); }