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 jeffjads · Nov 29, 2014 at 06:23 PM · rotationrigidbody.velocity

How to make the missile behave realistic by looking on the direction it is moving?

I want the missile to behave like this and i tried some solutions from here and here but they dont seem to work.

I hve this code:

 this.rigidbody.useGravity = true; 
 rigidbody.velocity = transform.TransformDirection(new Vector3(0, Force, 0));
 transform.rotation = Quaternion.LookRotation (rigidbody.velocity);

but it doesnt behave the way i wanted. Here's a picture from this link

alt text

EDIT:

here's the picture of the orientation of the missile in xyz axes

alt text

sasasaaa.png (139.6 kB)
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by fafase · Nov 29, 2014 at 06:24 PM

You could try this:

 transform.up= rigidbody.velocity.normalized;
Comment
Add comment · Show 11 · 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 jeffjads · Nov 29, 2014 at 06:29 PM 0
Share

im sorry but that doesnt did the trick. im simulating a ballistic trajectory. everything is fine but the rotation of the missile is not realistic

avatar image fafase · Nov 29, 2014 at 06:32 PM 0
Share

You mean it did not do anything or it did not do it as you expected?

avatar image jeffjads · Nov 29, 2014 at 06:35 PM 0
Share

it did not do it as i expected.

avatar image fafase · Nov 29, 2014 at 06:50 PM 0
Share

I have this example code on a cylinder and it works:

 public class NewBehaviourScript1 : $$anonymous$$onoBehaviour {
 
     public Transform camTr;
     void Start () 
     {
         rigidbody.AddForce(new Vector3(1000f,1000f,0));
     }
     void Update() 
     {
         camTr.position = transform.position;
         var pos = camTr.position;
         pos.z = -15f;
         camTr.position = pos;
     }
     void LateUpdate () 
     {
         transform.up = rigidbody.velocity.normalized;
     }
 }

The camTr variable is just to have the camera following at a distance.

The force is applied once with AddForce (which I recommend use to use) Then I just look at the capsule moveing and falling down.

avatar image Cherno · Nov 29, 2014 at 08:04 PM 0
Share

You just need to rotate the missile towards the same vector that is used for movement.

Show more comments
avatar image
0

Answer by psycocrusher · Nov 29, 2014 at 08:23 PM

Why don't you use a transform.LookAt

http://docs.unity3d.com/ScriptReference/Transform.LookAt.html

The Z axis needs to point forward on the missile.

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 jeffjads · Nov 30, 2014 at 02:11 AM 0
Share

transform.LookAt -- the missile always look and moves upward direction.

 transform.LookAt (rigidbody.velocity);

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Tank moving to the right slightly 1 Answer

Flip over an object (smooth transition) 3 Answers

Rigidbody angularvelocity shortest way 1 Answer

Problem with rotation and groundchek _ 2D - C# 1 Answer

Rotating object using touch controls mobile 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