Hey everyone got some questions and yes I know Im total noob…
-
How can I improve my ship movement script? It seems a bit buggy when turning for some reason almost like bending space but its ok I guess…also how can I tilt the ship slightly when turning? I am going for a STO style ship control system thing.
using UnityEngine;
using System.Collections;
public class ShipControl : MonoBehaviour {
public Transform ship; float flyingSpeed = 0; float turnSpeed = 50.0f; void Update () { //Accelerate the ship using the thrust key. if(Input.GetKeyDown("e")) { if(flyingSpeed == 0) { flyingSpeed = 2.5f; ship.transform.Translate(0,-flyingSpeed * Time.deltaTime,0); } if(flyingSpeed == 2.5f) { flyingSpeed = 5f; ship.transform.Translate(0,-flyingSpeed * Time.deltaTime,0); } } //Decelerate the ship using the thrust button. if(Input.GetKeyDown("q")) { if(flyingSpeed == 5f) { flyingSpeed = 2.5f; } if(flyingSpeed == 2.5f) { flyingSpeed = 0; } } if(Input.GetKey("w")) { ship.transform.Rotate(20.0f * Time.deltaTime, 0.0f, 0.0f); } if(Input.GetKey("s")) { ship.transform.Rotate(-20.0f * Time.deltaTime, 0.0f, 0.0f); } if(Input.GetKey("d")) { ship.transform.Rotate(0.0f, turnSpeed * Time.deltaTime, 0.0f * Time.deltaTime, Space.World); //and then turn the plane } if(Input.GetKey("a")) { ship.transform.Rotate(0.0f, -turnSpeed * Time.deltaTime, 0.0f * Time.deltaTime, Space.World); //and then turn the plane } ship.transform.Translate(0,-flyingSpeed * Time.deltaTime,0); }
}
-
Edit: Solved!
-
Edit: Solved!
-
Is there a way I can make two ships collide by just making a collision sphere on both that detect each other? I don’t need all the fancy physics, using transform for movement currently.