Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Behamut · May 22, 2015 at 03:36 PM · movement scriptrotate objectmove an objecthelicopter

Helicoper Movement Help

Hi all,

I'm working on a helicopter game, but I'm not able to get the helicopter moving properly. I was able to make it move forward, backward, side to side and tilt in the direction of movement, but so far, I was not able to make it rotate without lossing the tilt movement. The helicopter includes a rigidbody attached but at this point I really don't care on using physics as i'm trying to emulate an old game so the movement can be character control insted of physics, but then, i was not able to make it work by that way either

Here is what I achived so far: https://dl.dropboxusercontent.com/u/86664182/helicopterMovement.gif

Here is an example on how I want the helicopter to behave: https://www.youtube.com/watch?v=teMUuNksdek

And here is the code that is attached to the helicopter:

 using UnityEngine;
 using System.Collections;
 
 public class HelicopterController : MonoBehaviour {
 
     public GameObject helix;
     public GameObject secondaryHelix;
     public float rotationSpeed;
     public float speed;
     public float tilt; // The amount of rotation in one side or the other when moving
     public float turnSpeed = 30f;
 
     void FixedUpdate()
     {
         float moveHorizontal = Input.GetAxis("Horizontal");
         float moveVertical = Input.GetAxis("Vertical");
 
         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
         GetComponent<Rigidbody> ().velocity = movement * speed;
 
 
         GetComponent<Rigidbody> ().rotation = Quaternion.Euler (GetComponent<Rigidbody> ().velocity.z * tilt, 0.0f, GetComponent<Rigidbody> ().velocity.x * -tilt);
 
         //Try to rotate the helicpter while moving forward and backward - did't work
 //        if(Input.GetKey(KeyCode.Q))
 //            transform.Rotate(Vector3.up, -turnSpeed * Time.deltaTime);
 //        
 //        if(Input.GetKey(KeyCode.E))
 //            transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime);
     
     }
 
     void Update()
     {
 
 
 
         helix.transform.Rotate (new Vector3 (0.0f, rotationSpeed, 0.0f));
         secondaryHelix.transform.Rotate (new Vector3 (rotationSpeed, 0.0f, 0.0f));
     }
 }


Thanks in advance.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by FortisVenaliter · May 22, 2015 at 03:52 PM

You probably want it to rotate around the transform.up (local) axis rather than the Vector3.up (world) axis.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Behamut · May 27, 2015 at 06:32 PM 0
Share

Thanks, will do that.

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Two problems One code 1 Answer

How can I make a prefab object from a list to move?,How can I make an object from a list to move by itself? 2 Answers

How can I add a delay between moving objects ? 1 Answer

Helicopter Controls 1 Answer

How to rotate a GameObject around another object according to the mouse cursor position in C# 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges