Skip to main content
add formatting code
Origen Enlace
Angel Angel
  • 10.1k
  • 9
  • 44
  • 69

scritp autoria de kaito

funciona genial.

using UnityEngine;

using System.Collections;

//El script se añade a la camara [RequireComponent(typeof(Camera))]

public class script3 : MonoBehaviour {

using UnityEngine;

using System.Collections;

//El script se añade a la camara
[RequireComponent(typeof(Camera))]

public class script3 : MonoBehaviour {

    public Transform target; //Gameobject que hace de pivot
    public float smoothTime = 0.5f; //tiempo smooth
    public Vector2 desplazamiento = new Vector2(3f, 2f); //desplazamiento de origen
    public Vector2 resolucion = new Vector2(800f,600f); //resolucion de origen


    Vector3 velocity = Vector3.zero; //velocidad smooth
    Vector3 centerScreen; //centro pantalla
    Vector3 aspect; //aspecto ratio


    void Start() {


        if(this.target == null){

            Destroy(this);
            Debug.Log("Asignar Target en script3 - " + this.name);
            Debug.Break();
            return;

        }

        this.centerScreen = new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, 0f);
        //Recalcular desplazamiento en relacion a pantalla actual
        this.desplazamiento = new Vector2(this.desplazamiento.x * Screen.width / this.resolucion.x,
                                          this.desplazamiento.y * Screen.height / this.resolucion.y);
        this.aspect = new Vector3(this.desplazamiento.x / Screen.width, this.desplazamiento.y / Screen.height, 0f);

    }

    void Update () {

        Vector3 temp = this.target.position + Vector3.Scale(Input.mousePosition - this.centerScreen, this.aspect);
        this.transform.position = Vector3.SmoothDamp(this.transform.position, temp, ref this.velocity, this.smoothTime);
    
    }

}

}

scritp autoria de kaito

funciona genial.

using UnityEngine;

using System.Collections;

//El script se añade a la camara [RequireComponent(typeof(Camera))]

public class script3 : MonoBehaviour {

public Transform target; //Gameobject que hace de pivot
public float smoothTime = 0.5f; //tiempo smooth
public Vector2 desplazamiento = new Vector2(3f, 2f); //desplazamiento de origen
public Vector2 resolucion = new Vector2(800f,600f); //resolucion de origen


Vector3 velocity = Vector3.zero; //velocidad smooth
Vector3 centerScreen; //centro pantalla
Vector3 aspect; //aspecto ratio


void Start() {


    if(this.target == null){

        Destroy(this);
        Debug.Log("Asignar Target en script3 - " + this.name);
        Debug.Break();
        return;

    }

    this.centerScreen = new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, 0f);
    //Recalcular desplazamiento en relacion a pantalla actual
    this.desplazamiento = new Vector2(this.desplazamiento.x * Screen.width / this.resolucion.x,
                                      this.desplazamiento.y * Screen.height / this.resolucion.y);
    this.aspect = new Vector3(this.desplazamiento.x / Screen.width, this.desplazamiento.y / Screen.height, 0f);

}

void Update () {

    Vector3 temp = this.target.position + Vector3.Scale(Input.mousePosition - this.centerScreen, this.aspect);
    this.transform.position = Vector3.SmoothDamp(this.transform.position, temp, ref this.velocity, this.smoothTime);

}

}

scritp autoria de kaito

funciona genial.

using UnityEngine;

using System.Collections;

//El script se añade a la camara
[RequireComponent(typeof(Camera))]

public class script3 : MonoBehaviour {

    public Transform target; //Gameobject que hace de pivot
    public float smoothTime = 0.5f; //tiempo smooth
    public Vector2 desplazamiento = new Vector2(3f, 2f); //desplazamiento de origen
    public Vector2 resolucion = new Vector2(800f,600f); //resolucion de origen


    Vector3 velocity = Vector3.zero; //velocidad smooth
    Vector3 centerScreen; //centro pantalla
    Vector3 aspect; //aspecto ratio


    void Start() {


        if(this.target == null){

            Destroy(this);
            Debug.Log("Asignar Target en script3 - " + this.name);
            Debug.Break();
            return;

        }

        this.centerScreen = new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, 0f);
        //Recalcular desplazamiento en relacion a pantalla actual
        this.desplazamiento = new Vector2(this.desplazamiento.x * Screen.width / this.resolucion.x,
                                          this.desplazamiento.y * Screen.height / this.resolucion.y);
        this.aspect = new Vector3(this.desplazamiento.x / Screen.width, this.desplazamiento.y / Screen.height, 0f);

    }

    void Update () {

        Vector3 temp = this.target.position + Vector3.Scale(Input.mousePosition - this.centerScreen, this.aspect);
        this.transform.position = Vector3.SmoothDamp(this.transform.position, temp, ref this.velocity, this.smoothTime);
    
    }

}
cuerpo editado
Origen Enlace

scritp autoria de kaitokaito

funciona genial.

using UnityEngine; using

using System.Collections;

//El script se añade a la camara [RequireComponent(typeof(Camera))] public

public class script3 : MonoBehaviour {

public Transform target; //Gameobject que hace de pivot
public float smoothTime = 0.5f; //tiempo smooth
public Vector2 desplazamiento = new Vector2(3f, 2f); //desplazamiento de origen
public Vector2 resolucion = new Vector2(800f,600f); //resolucion de origen


Vector3 velocity = Vector3.zero; //velocidad smooth
Vector3 centerScreen; //centro pantalla
Vector3 aspect; //aspecto ratio


void Start() {


    if(this.target == null){

        Destroy(this);
        Debug.Log("Asignar Target en script3 - " + this.name);
        Debug.Break();
        return;

    }

    this.centerScreen = new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, 0f);
    //Recalcular desplazamiento en relacion a pantalla actual
    this.desplazamiento = new Vector2(this.desplazamiento.x * Screen.width / this.resolucion.x,
                                      this.desplazamiento.y * Screen.height / this.resolucion.y);
    this.aspect = new Vector3(this.desplazamiento.x / Screen.width, this.desplazamiento.y / Screen.height, 0f);

}

void Update () {

    Vector3 temp = this.target.position + Vector3.Scale(Input.mousePosition - this.centerScreen, this.aspect);
    this.transform.position = Vector3.SmoothDamp(this.transform.position, temp, ref this.velocity, this.smoothTime);

}

}

scritp autoria de kaito

funciona genial.

using UnityEngine; using System.Collections;

//El script se añade a la camara [RequireComponent(typeof(Camera))] public class script3 : MonoBehaviour {

public Transform target; //Gameobject que hace de pivot
public float smoothTime = 0.5f; //tiempo smooth
public Vector2 desplazamiento = new Vector2(3f, 2f); //desplazamiento de origen
public Vector2 resolucion = new Vector2(800f,600f); //resolucion de origen


Vector3 velocity = Vector3.zero; //velocidad smooth
Vector3 centerScreen; //centro pantalla
Vector3 aspect; //aspecto ratio


void Start() {


    if(this.target == null){

        Destroy(this);
        Debug.Log("Asignar Target en script3 - " + this.name);
        Debug.Break();
        return;

    }

    this.centerScreen = new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, 0f);
    //Recalcular desplazamiento en relacion a pantalla actual
    this.desplazamiento = new Vector2(this.desplazamiento.x * Screen.width / this.resolucion.x,
                                      this.desplazamiento.y * Screen.height / this.resolucion.y);
    this.aspect = new Vector3(this.desplazamiento.x / Screen.width, this.desplazamiento.y / Screen.height, 0f);

}

void Update () {

    Vector3 temp = this.target.position + Vector3.Scale(Input.mousePosition - this.centerScreen, this.aspect);
    this.transform.position = Vector3.SmoothDamp(this.transform.position, temp, ref this.velocity, this.smoothTime);

}

}

scritp autoria de kaito

funciona genial.

using UnityEngine;

using System.Collections;

//El script se añade a la camara [RequireComponent(typeof(Camera))]

public class script3 : MonoBehaviour {

public Transform target; //Gameobject que hace de pivot
public float smoothTime = 0.5f; //tiempo smooth
public Vector2 desplazamiento = new Vector2(3f, 2f); //desplazamiento de origen
public Vector2 resolucion = new Vector2(800f,600f); //resolucion de origen


Vector3 velocity = Vector3.zero; //velocidad smooth
Vector3 centerScreen; //centro pantalla
Vector3 aspect; //aspecto ratio


void Start() {


    if(this.target == null){

        Destroy(this);
        Debug.Log("Asignar Target en script3 - " + this.name);
        Debug.Break();
        return;

    }

    this.centerScreen = new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, 0f);
    //Recalcular desplazamiento en relacion a pantalla actual
    this.desplazamiento = new Vector2(this.desplazamiento.x * Screen.width / this.resolucion.x,
                                      this.desplazamiento.y * Screen.height / this.resolucion.y);
    this.aspect = new Vector3(this.desplazamiento.x / Screen.width, this.desplazamiento.y / Screen.height, 0f);

}

void Update () {

    Vector3 temp = this.target.position + Vector3.Scale(Input.mousePosition - this.centerScreen, this.aspect);
    this.transform.position = Vector3.SmoothDamp(this.transform.position, temp, ref this.velocity, this.smoothTime);

}

}

Origen Enlace

scritp autoria de kaito

funciona genial.

using UnityEngine; using System.Collections;

//El script se añade a la camara [RequireComponent(typeof(Camera))] public class script3 : MonoBehaviour {

public Transform target; //Gameobject que hace de pivot
public float smoothTime = 0.5f; //tiempo smooth
public Vector2 desplazamiento = new Vector2(3f, 2f); //desplazamiento de origen
public Vector2 resolucion = new Vector2(800f,600f); //resolucion de origen


Vector3 velocity = Vector3.zero; //velocidad smooth
Vector3 centerScreen; //centro pantalla
Vector3 aspect; //aspecto ratio


void Start() {


    if(this.target == null){

        Destroy(this);
        Debug.Log("Asignar Target en script3 - " + this.name);
        Debug.Break();
        return;

    }

    this.centerScreen = new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, 0f);
    //Recalcular desplazamiento en relacion a pantalla actual
    this.desplazamiento = new Vector2(this.desplazamiento.x * Screen.width / this.resolucion.x,
                                      this.desplazamiento.y * Screen.height / this.resolucion.y);
    this.aspect = new Vector3(this.desplazamiento.x / Screen.width, this.desplazamiento.y / Screen.height, 0f);

}

void Update () {

    Vector3 temp = this.target.position + Vector3.Scale(Input.mousePosition - this.centerScreen, this.aspect);
    this.transform.position = Vector3.SmoothDamp(this.transform.position, temp, ref this.velocity, this.smoothTime);

}

}