OtroIntentoDe

ControlCamara

Sep 17th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class ControlCamara : MonoBehaviour {
  6.     public GameObject Jugador;
  7.     public GameObject referencia;
  8.     private Vector3 distancia;
  9.  
  10.     void Start () {
  11.         distancia = transform.position - Jugador.transform.position;
  12.     }
  13.  
  14.     void LateUpdate (){
  15.         distancia = Quaternion.AngleAxis (Input.GetAxis ("Mouse X") * 2, Vector3.up) * distancia;
  16.         distancia = Quaternion.AngleAxis (Input.GetAxis ("Mouse Y") * 2, Vector3.right) * distancia;
  17.  
  18.  
  19.         transform.position = Jugador.transform.position + distancia;
  20.         transform.LookAt (Jugador.transform.position);
  21.  
  22.         Vector3 CopiaRot = new Vector3 (0, transform.eulerAngles.y, 0);
  23.         referencia.transform.eulerAngles = CopiaRot;
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment