using System.Collections; using System.Collections.Generic; using UnityEngine; public class dragoncontrols : MonoBehaviour { public float speed = 300; float xinput = 0; float yinput = 0; float zinput = 0; float xrot = 0; float yrot = 0; public float rotspeed = 360; bool flamethrover = false; Rigidbody rb; ParticleSystem flames; // Start is called before the first frame update void Start() { rb = GetComponent(); flames = GetComponentInChildren(); speed *= rb.mass; } // Update is called once per frame void Update() { } void FixedUpdate() { zinput = Input.GetAxis("Horizontal") * speed; xinput = Input.GetAxis("Vertical") * speed; yinput = Input.GetAxis("Jump") * speed; xrot = Input.GetAxis("Rot") * speed; yrot = Input.GetAxis("Yrot") * speed; flamethrover = Input.GetButton("Fire1"); //control flames if (flamethrover) { flames.Play(); } else { flames.Stop(); } //move relative to camera //transform.Translate(xinput * Time.deltaTime * 4, yinput * Time.deltaTime * 4, zinput * Time.deltaTime); //move relative to camera addforce //rb.AddForce(xinput * Time.fixedDeltaTime * 2, yinput * Time.fixedDeltaTime * 4, zinput * Time.fixedDeltaTime); //add force relative to rotation Vector3 inputs = new Vector3(xinput * Time.fixedDeltaTime * 2, yinput * Time.fixedDeltaTime * 4, zinput * Time.fixedDeltaTime); rb.AddForce(transform.TransformDirection(inputs)); //add rotation from ziput //transform.Rotate(0, zinput * Time.deltaTime * rotspeed, xrot * Time.deltaTime / 2 * rotspeed); //set rotation from ziput addforce Vector3 m_EulerAngleVelocity = new Vector3(0, yrot * Time.fixedDeltaTime * rotspeed, xrot * Time.fixedDeltaTime / 2 * rotspeed); Quaternion deltaRotation = Quaternion.Euler(m_EulerAngleVelocity * Time.fixedDeltaTime); rb.MoveRotation(deltaRotation); } }