Problem with mouseorbit android
Hi all, these script work well in PC but in android doesn't work well, how make these script work in android in joystick , buttons or anything??
This script is for player
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);
}
}
This is more dificult for work in android joystick is the camara script, there are javascript but np
#pragma strict
var target : Transform;
var distance = 10.0;
var xSpeed = 250.0;
var ySpeed = 120.0;
var yMinLimit = -20;
var yMaxLimit = 80;
/*
var xMinLimit = -20;
var xMaxLimit = 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);
//x = ClampAngle(x, xMinLimit, xMaxLimit);
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);
}
Pd: Sorry for my english
Those scripts rely on Input.GetAxis() and get mouse movements with it's help. So you need to replace it with something that will work on desired platform.
Also notice that you have several possible ways of input that can replace mouse input. Consider which one is more suitable for you and implement it.
Your answer
Follow this Question
Related Questions
VR Scene Rotation on Build 0 Answers
can i find whats the problem of the script of free camera rotation ?? 1 Answer
How do I rotate a sphere while swiping, in the direction that I am swiping ? 0 Answers
if the Android/ios device rotate (x) degrees do animation 0 Answers
أنجازات غير مسبوقة؟؟!!توكيل كاريير +بالاسكندرية 01286629661 0 Answers