2022-12-01 09:03:46 +01:00
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class CameraController : MonoBehaviour
|
|
|
|
|
{
|
2023-02-16 14:55:48 +01:00
|
|
|
public GameObject player; //jatekos objektum
|
|
|
|
|
public Camera camera; //fo kamera
|
|
|
|
|
private Vector3 offset; //kamera pozicio
|
|
|
|
|
public float xPostion = 0; //x tengely pozicio
|
2023-02-02 10:58:27 +01:00
|
|
|
|
2023-02-16 14:55:48 +01:00
|
|
|
private void Start(){ //kezdeskor a kamera ugorjon a jatekos moge
|
2023-02-02 10:58:27 +01:00
|
|
|
offset.x = xPostion;
|
|
|
|
|
offset.y = camera.transform.position.y - player.transform.position.y;
|
|
|
|
|
offset.z = camera.transform.position.z - player.transform.position.z;
|
2022-12-01 09:03:46 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-16 14:55:48 +01:00
|
|
|
private void LateUpdate(){ //kamera pozicio frissitese
|
2023-02-02 10:58:27 +01:00
|
|
|
if(player.transform.position.x != 3 || player.transform.position.x != -3)
|
|
|
|
|
camera.transform.position = player.transform.position + offset;
|
2022-12-01 09:03:46 +01:00
|
|
|
}
|
2023-02-02 10:58:27 +01:00
|
|
|
}
|