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 allesisda · Jan 23, 2013 at 07:59 PM · collisionpositionvelocity

Quadrocopter flight

hi there,

i am trying to make a kind of flight simulator with a quadrocopter but i am having some (in fact a lot) problems with the control...

i think that it should be easy, but i dont get it...

i want to have a float "power" that makes it go up (in local Y) and than rotate it, so that the power can be used to go forward OR to go up... (if it is going forward it should go down at the same time)

my first test went quite goot, but my copter ignored collisions. so i tried to make a rigidbody and apply velocities on it. but its a lot more complicated -.-

so in fact i need rotation around the X,Y,Z axis and local up down on the local Y (with gravity)

do you have some ideas?

Comment
Add comment · Show 2
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 iwaldrop · Jan 23, 2013 at 08:11 PM 0
Share

People here have many ideas but not a lot of time. What's the actual question?

avatar image allesisda · Jan 23, 2013 at 08:24 PM 0
Share

how can i set a local y velocity, that also allows collision?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by iwaldrop · Jan 23, 2013 at 08:31 PM

  1. Attach a Rigidbody to your copter (sounds like you've already done this).

  2. Use rigidbody.AddForce() and rigidbody.AddTorque() to manipulate it.

Quadrocopters usually either rotate their blades to vector their lift or control their RPMs individually; so you should probably attempt to apply force at the rotors. This will lead to an accurate simulation of how they work. If you're not worried about physics accuracy, then just use a single rigidbody for the fuselage and provide force/torque input to that.

Comment
Add comment · Show 4 · 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 allesisda · Jan 23, 2013 at 08:56 PM 0
Share

thanks for the answer!

if i use addforce it gets faster and faster. is there a way to "read" the force/torque that is on it, for setting it back to 0 if i need to?

avatar image iwaldrop · Jan 23, 2013 at 10:05 PM 0
Share

Oh...well, you mentioned the y axis, so gravity should be applied to counteract the force.

If you're not doing it that way then expriment with transform.Translate().

Again, IRL the copter's rotors would apply less force/thrust at one corner, allowing that side to drop, providing vectored thrust across the aggregate of rotors. If you're not doing it that way you're going to have to play with your 'simulation'.

avatar image allesisda · Jan 24, 2013 at 12:59 PM 0
Share

okey... lets say, i make it applying force on each rotor... how do i make it? if i add force to each rotor they simply fly away... :/

avatar image allesisda · Feb 01, 2013 at 01:23 PM 0
Share

i tried the Addforceposition but the force is in worldscale and not local :/

this is my code at the moment:

public GameObject rotor1, rotor2, rotor3, rotor4;

 public float speed=200,time;
 Vector3 rotorspeed1;


 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
     rotorspeed1 = new Vector3(0,speed * Time.deltaTime,0);


     if (Input.Get$$anonymous$$ey("s"))
     {

         ApplyForce(rigidbody, rotor1);
     }
     if (Input.Get$$anonymous$$ey("w"))
     {

         ApplyForce(rigidbody, rotor2);
     }
     if (Input.Get$$anonymous$$ey("d"))
     {

         ApplyForce(rigidbody, rotor3);
     }
     if (Input.Get$$anonymous$$ey("a"))
     {

         ApplyForce(rigidbody, rotor4);
     }




     //reset:
     if (Input.Get$$anonymous$$ey("r"))
     {

         transform.position = new Vector3(0, 0.5f, 0);
         transform.eulerAngles = new Vector3(0, 0, 0);
         rigidbody.is$$anonymous$$inematic = true;
         
         
     }

     time += 1 * Time.deltaTime;
     if (time > 1)
     {
         time = 0;
         rigidbody.is$$anonymous$$inematic = false;
     }


 }// end update

 void ApplyForce(Rigidbody body,GameObject r)
 {
     
     body.AddForceAtPosition(rotorspeed1, r.transform.position);
     rigidbody.AddRelativeForce(rotorspeed1*3);
 }

} //end class

avatar image
0

Answer by Pysassin · Jan 23, 2013 at 10:10 PM

You can also use rigidbody.AddRelativeForce which would allow separate force numbers for up(y) forward(z) and side to side (x).

Comment
Add comment · 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

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

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to detect collision position and velocity? 2 Answers

Time when 2 objects will touch 1 Answer

When does a pos of a gameObject change from its velocity? 1 Answer

I want collision boxes to be precise without overlapping each other 1 Answer

Why is the relativeVelocity of a Collision always zero in OnCollisionEnter and OnCollisionStay? 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