Noticias

¡RECUERDA QUE SI ERES UN NUEVO USUARIO, DEBES PRESENTARTE PARA PODER PUBLICAR MENSAJES! | TENEMOS CANAL OFICIAL DE TELEGRAM: t.me/unity3dspain

MouseOrbit para android

Iniciado por , Enero 05, 2016, 07:13:30 PM

Tema anterior - Siguiente tema
Hola chicos hace tiempo que no me paso por aqui tengo un problema que llevo un tiempo intentando solucionar y no encuentro la manera.Estos 2 scripts me van bien para PC . El primero hace rotar un objeto en el eje x 360 grados. El otro es la camara que da vueltas alrededor del 1 objeto con su misma rotacion. El tema es que quiero pasarlo a android con un joystick, botones o cualquier cosa pero de momento no se hacerlo.Este es el script del player que rota es en c#using UnityEngine;using System.Collections; public class rotacion : MonoBehaviour { public float xSpeed = 250.0f; private float x;private float y; void Awake(){Vector3 angles = transform.eulerAngles;x = angles.x;y = angles.y; if(GetComponent<Rigidbody>() != null){rigidbody.freezeRotation = true;}} void LateUpdate(){x += (float)(Input.GetAxis("Mouse X") * xSpeed * 0.02f); Quaternion rotation = Quaternion.Euler(y, x, 0); transform.rotation = rotation;} private float ClampAngle(float angle, float min, float max){if(angle < -360){angle += 360;}if(angle > 360){angle -= 360;}return Mathf.Clamp (angle, min, max);}}  Y este el script de la camara que es el mas dificil para implementar en android de momento no he podido hacer lo mismo que hace en el PC (javascript)#pragma strict var target : Transform;var distance = 10.0; var xSpeed = 250.0;var ySpeed = 120.0; var yMinLimit = -20;var yMaxLimit = 80; private var x = 0.0;private var y = 0.0; function Start () {    var angles = transform.eulerAngles;    x = angles.y;    y = angles.x; // Make the rigid body not change rotation           if (GetComponent.<Rigidbody>())GetComponent.<Rigidbody>().freezeRotation = true;} function LateUpdate () {    if (target) {        x += Input.GetAxis("Mouse X") * xSpeed * 0.02;        y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02;                                  y = ClampAngle(y, yMinLimit, yMaxLimit);                                    var rotation = Quaternion.Euler(y, x, 0);        var position = rotation * Vector3(0.0, 0.0, -distance) + target.position;                transform.rotation = rotation;        transform.position = position;    }} static function ClampAngle (angle : float, min : float, max : float) {if (angle < -360)angle += 360;if (angle > 360)angle -= 360;return Mathf.Clamp (angle, min, max);}Espero que podeis ayudarme llevo como 1 mes intentandolo, sino encuentro solucion aqui lo dejo.


NO ESTA SOLUCIONADO, como lo pongo con botones o con un joystick ? Lo que no me sale es la camara, la rotacion del player la tengo mas o menos controlada.

Etiquetas: