Greetings,
I’m trying to create a skydiving simulator and I’m having problem with controlling it’s movement. I want player to only control the rotation and the velocity shall be calculated depending on the rotation and player’s current falling speed.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System;
[Serializable]
public class PrettyPlayer : MonoBehaviour {
[SerializeField]
private GameObject playerObject;
private IInputController controller;
private Rigidbody rigid;
[SerializeField]
private float playerSpeed;
[SerializeField]
private float maxSpeed;
[SerializeField]
private float rotateSpeed;
public Text DebugText;
public float Score;
void Awake ()
{
#if UNITY_ANDROID && !UNITY_EDITOR
controller = new MobileController();
#else
controller = new KeyboardController();
#endif
rigid = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
Move(playerSpeed);
}
void Move(float speed)
{
float inputHor = controller.InputHorizontal();
float inputVert = controller.InputVertical();
transform.Rotate(new Vector3(0, inputHor * Time.deltaTime * rotateSpeed ) );
transform.Rotate (new Vector3( inputVert * Time.deltaTime * rotateSpeed, 0));
}
}