Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class ThirdPersonCamera : MonoBehaviour
- {
- //offset va a ser la distancia entre la camara y la esfera que es nuestro player
- public Vector3 offset;
- private Transform target;
- [Range(0,1)] public float lerpValue;
- public GameObject Player;
- public GameObject referencia;
- public Vector3 distancia;
- public string controlInvertido;
- // Start is called before the first frame update
- void Start()
- {
- target = GameObject.FindWithTag("Player").transform;
- }
- // Update is called once per frame
- void Update()
- {
- }
- //Método de Unity que lo que hace es ejecutarse al final de cada fotograma
- private void LateUpdate()
- {
- transform.position = Vector3.Lerp(transform.position, target.position + offset, lerpValue);
- transform.LookAt(target);
- //Eje Y vista izquierda y derecha
- // Tengo que arreglar esto para el principio Don't Repeat your self
- offset = Quaternion.AngleAxis(Input.GetAxis("Mouse X") * 2, Vector3.up) * offset;
- transform.position = target.transform.position + offset;
- transform.LookAt(target.transform.position);
- /*
- offset = Quaternion.AngleAxis(Input.GetAxis("Joystick 4") * 2, Vector3.up) * offset;
- transform.position = target.transform.position + offset;
- transform.LookAt(target.transform.position);
- */
- //Eje X vista hacia abajo y arriba
- offset = Quaternion.AngleAxis(Input.GetAxis("Mouse Y") * 2, -Vector3.right) * offset;
- transform.position = target.transform.position + offset;
- transform.LookAt(target.transform.position);
- Debug.Log("vista eje X: " + offset);
- /*
- offset = Quaternion.AngleAxis(Input.GetAxis("Joystick 5") * 2, -Vector3.right) * offset;
- transform.position = target.transform.position + offset;
- transform.LookAt(target.transform.position);
- */
- //referencia para que los controles esten bien rotados
- Vector3 copiaRotacion = new Vector3(0, transform.eulerAngles.y, 0);
- referencia.transform.eulerAngles = copiaRotacion;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement