• 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
Question by adammc · Oct 03, 2011 at 01:43 PM · rigidbodyforcefollowtorquemissile

Guided Missile

Missile in my game is not acting as i expect.

See attached image of the trajectory of my missile. Start point is upper right corner of the image. Missile is guided to target by AddTorque. Target is the large grey cube. As the missile is fired to a stationary target--head-on, i would expect the missile to be guided directly to the target-not narrowly missing the target.

alt text

Attempting to simulate Aim-9 sidewinder missile

(quick specs) weight: 85kg thrust: ~19 kN (classified, estimated value, older versions ~17 kN) max speed: mach 2.5 (680.58 m/s)

The physics in my game are the following:

Missile is a Rigidbody Mass 85 Drag 0.25 Angular Drag 20 Use Gravity yes Kinematic no

Controlling Script below

 Start()
 {
     //Fired from moving jet.
     rigidbody.isKinematic = false;
     rigidbody.velocity = this.parentRB.velocity;

     //19000 is 19 kN of estimated thrust form Aim-9 missile
     constantForce.relativeForce = Vector3.forward * 19000;
 }


 FixedUpdate()
 {
     var x : Transform;
 x = transform;        
 x.LookAt(target.transform);
             
 rigidbody.AddTorque(x.position * 0.1);
 }



Any advice on how to better simulate the missile would be appreciated. Thanks

Comment

People who like this

0 Show 3
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 BerggreenDK · Oct 03, 2011 at 02:24 PM 0
Share

I havent tested your code, but as far as I understand physics, you need to do those calculations in the FixedUpdate. Secondly, why do you use the X position of a missile moving forward? Z is forward.

avatar image Owen-Reynolds · Oct 03, 2011 at 02:37 PM 0
Share

AddTorque spins you, so I'm guessing its job is to turn the missle towards the target. BUT, the line x.LookAt(target.transform) snaps the missile directly there.

Also, AddTorque takes an axis as input, not a position. If you fire a missile facing +z while at the far-right bottom of the map, say (1000,0,0) your AddTorque command tells the missle to tumble over the x-axis, doing crazy loops.

I'm guessing the "real world" solution is to get rid of LookAt and figure how to AddTorque over the proper angle (but then you'll have problems with oversteering -- I'm guessing real missiles had the same problem and the guidance chips are doing lots of math, today.)

avatar image Owen-Reynolds · Oct 04, 2011 at 04:36 PM 0
Share

BerggreenDK: He isn't really using the X-position. He's using the "look up the transform first" trick. It's rumored that writing transform is really doing a search through your components to find your transform. If you write x=transform; and then use x.this and x.that, you only do that time-wasting search once.

So, x.position on the last line is really transform.position. But, yeah, I'd have gone with T instead of x.

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Moving a rigid body on a plane applying forces 1 Answer

Rotation Force on a model 2 Answers

AddRelativeTorque not rotating 1 Answer

Apply force and torque on different collider enter 0 Answers

Returning a rigidbody back to its original x and z rotations through physics forces. 2 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