Hello,
I am trying currently trying to make a flying game I need some tips or show me how to make the plane fly. How to remove gravity etc thank you hope you can show me and help me
Check the wiki to see if there is any useful scripts.
Here’s a simple script that should work. Add this script to your airplane with a collider and a rigidbody. Uncheck the box in the rigidbody that says use gravity.
var moveSpeed = 25;
var rotateSpeed = 90;
private var moveDirection = Vector3.zero;
private var targetDirection = Vector3.zero;
function Awake () {
moveDirection = transform.TransformDirection(Vector3.forward);
}
function Update () {
CalculateMovement ();
transform.rotation = Quaternion.LookRotation(moveDirection);
rigidbody.velocity = transform.TransformDirection(Vector3.forward) * moveSpeed * Time.deltaTime;
}
function CalculateMovement () {
var forward = transform.TransformDirection(Vector3.forward);
var right = Vector3(forward.z, 0, -forward.x);
var v = Input.GetAxis("Mouse Y");
var h = Input.GetAxis("Mouse X");
targetDirection = v * forward + h * right;
if(targetDirection != Vector3.zero) {
moveDirection = Vector3.RotateTowards(moveDirection, targetDirection, rotateSpeed * Mathf.Deg2Rad * Time.deltaTime, 1000);
moveDirection = moveDirection.normalized;
}
}
I took it mostly from the third person controller.
I want to make a flying style like Ace online ( airrivals same thing) a game like that and ty for the info ill try that out ^^ and whats the wiki site?
if I were you, I wouldn’t remove gravity. Learn a bit about how airplanes fly, and try applying that in your game-physics: that’s the only way to get a realistic feeling to the game. This will also make it a lot easier for you to if you want to add different kinds of airplanes.
Unity can use quaternions for movement, which is great for airplanes, spaceships, etc., so it shouldn’t be that hard to make the controls realisticly.
Here’s the link for the wiki.
http://www.unifycommunity.com/wiki/index.php?title=Main_Page