- Home /
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.
"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.
Answer by TaigaStudios · Jul 06, 2010 at 08:06 PM
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
This is a HELP AND ANSWER FORU$$anonymous$$!!! not tell other people to do it them self site
Your answer
Follow this Question
Related Questions
How to make objects invisible on collision? 2 Answers
Spawning Zombies Different Rounds 2 Answers
AI damage problem 0 Answers
How do i make a fighting system like in oblivion? 1 Answer
Rotating a camera when RMB is held down. 0 Answers