x


Flying/hover script?

Hi, i have been making a game with a hover and helicopter. with my script here

using UnityEngine;
using System.Collections;

public class ThrusterScript : MonoBehaviour {
   // declare the variables
   public float Speed = 9;
   public float Drag = 20;
   public float DragNoMovement = 50;
   const float  airDrag = 0F;

   void FixedUpdate () {
      // get the inputs
      float horizontal = Input.GetAxis ("Horizontal");
      float vertical = Input.GetAxis ("Vertical");
      float altitude = Input.GetAxis ("UpDown");

      // check to see if the user is moving
      bool userMoved = Mathf.Abs (horizontal) > 0.1F || Mathf.Abs (vertical) > 0.1F || Mathf.Abs (altitude) > 0.1F;

      // determine the force vector
              float x = horizontal * Speed;         
      float z = vertical * Speed;
      float y = altitude * Speed;
      rigidbody.AddRelativeForce (new Vector3 (x, y, z), ForceMode.VelocityChange);

      // apply the appropriate drag when moving
      if (userMoved)
         rigidbody.drag = Drag;
      else
         rigidbody.drag = DragNoMovement;
   }


   void Start () {
      if (rigidbody==null)
         gameObject.AddComponent ("Rigidbody");

      // don't let the physics engine rotate the character
      rigidbody.freezeRotation = true;
   }
} 

It gave me a ton of errors.How can i fix it? And if possible, could anyone give me a script for aeroplanes/hover/helicopers? I saw the helicopter script from Andrew Gotow, but i cant get it to work.Please help, really need it, thanks.

more ▼

asked Jul 05 '10 at 08:22 AM

user-3061 (yahoo) gravatar image

user-3061 (yahoo)
126 29 29 37

"It gave me a ton of errors" is NOT helpful at all. What errors, specifically, did you get? -- And no, noone will "give you a script", you need to write your own code, we don't do your work for you.

Jul 05 '10 at 09:29 AM qJake

@SpikeX

go eat peanut butter and shut up

Aug 28 '12 at 01:53 PM Yoman
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

As SpikeX be more specific of your errors and first give it a try to solve the problem yourself. If youre using someone else's tutorial take the complete project and edit for your needs to avoid typo errors. Here is a list of Vehicle Tutorials For your project i would recommend the third link (car tutorial) which leads you to page where you can find helicopter tutorial. Here's DL for the Helicopter Tutorial

more ▼

answered Jul 06 '10 at 08:06 PM

TaigaStudios gravatar image

TaigaStudios
242 3 4 16

Thanks for the endorsement Taiga Studios!

Nov 24 '10 at 03:26 PM Mani

This is a HELP AND ANSWER FORUM!!! not tell other people to do it them self site

Aug 28 '12 at 01:54 PM Yoman

@yoman encouragin ppl to learn for themselves is helping.

Aug 28 '12 at 01:57 PM Mander
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x132
x68
x35

asked: Jul 05 '10 at 08:22 AM

Seen: 4431 times

Last Updated: Aug 28 '12 at 01:57 PM