Hola estoy intentando poder inclinar una nave con el joystick pero no he podido. ¿como podría hacerlo? si me pudieran ayudar porfavor se los agradecería mucho.Este es el codigo que me funciona sin el joystick:
using UnityEngine;
using System.Collections;
public class PlayerController2 : MonoBehaviour
{
public float speed;
public float tilt;
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, moveVertical, 0.0f);
GetComponent<Rigidbody>().velocity = movement * speed;
GetComponent<Rigidbody>().rotation = Quaternion.Euler(0.0f, 0.0f, GetComponent<Rigidbody>().velocity.x * -tilt);
}
}
pero aqui muevo la nave con el joystick:
using UnityEngine;
using System.Collections;
using UnitySampleAssets.CrossPlatformInput;
public class MoverNave : MonoBehaviour
{
float sense = 5;
public float speed;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Translate(new Vector3(0, CrossPlatformInputManager.GetAxis("Vertical")) * Time.deltaTime * speed);
float y = CrossPlatformInputManager.GetAxis("Mouse Y") * sense;
transform.Rotate(0, y, 0);
transform.Translate(new Vector3(CrossPlatformInputManager.GetAxis("Horizontal"), 0) * Time.deltaTime * speed);
float x = CrossPlatformInputManager.GetAxis("Mouse X") * sense;
transform.Rotate(x, 0, 0);
}
}
}
}
I have been searching but not have found the solution for my problem....