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 GutoThomas · Jun 11, 2012 at 04:49 AM · physicsrigidbodyvector3launch

Oblique launch problem

Hey everyone. Weeks ago I posted here about the same subject. I want to make some kind of oblique launch, from start to goal. There's no problem in this because I can just try some things using values based on distance between start and goal or also use high school physics, but my problem is to make the projectile go forward. I'm not managing to 'join' the velocity that the projectile need to get to the goal with the forward vector3 of the empty who launch the projectile.

If I have something like this:

 Vector3 emptyForward = myEmpty.forward;
 Vector3 velocity = new Vector3(// some maths here to find a nice vec3 for the velocity, whatever);

So now, how I'll procede to 'join' emptyForward with velocity? Remembering that the velocity Vec3 will be applied to the rigidbody.

 rigidbody.velocity = velocity;

Here's an image of the disared path:

alt text

Thanks from now!

eg.jpg (37.0 kB)
Comment
Add comment · Show 4
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 syclamoth · Jun 11, 2012 at 05:02 AM 0
Share

Just use high-school physics. Imagine it in a 2-dimensional plane, and then use 'transform.TransformDirection' to convert in into a 3-dimensional vector!

avatar image GutoThomas · Jun 11, 2012 at 05:06 AM 0
Share

Good! TransformDirection should work! What kind of way should I use to get the distance? (goal - start).sqr$$anonymous$$agnitude or (goal.x - start.x, ....) Each one will produce different results?

avatar image syclamoth · Jun 11, 2012 at 05:18 AM 1
Share

sqr$$anonymous$$agnitude gives you the distance squared, which isn't exactly what you want. I'd use Vector3.Distance(start, end) for the total distance, but in this case that's not exactly what you want- you need to work out the 2-dimensional vector (for the high-school physics bit). In this case, I'd rotate the transform so that it points towards the target point (make sure it doesn't point up or down, so adjust the y-axis of the target point to fake it being level with the transform), then use InverseTransformPoint to find the vector to the actual target. In doing so, you should be able to discard the x-coordinate, and do your calculation using the y-coord as the height, and the z-coord as the distance. Having calculated the vector with that, use TransformDirection to get the vector back into world coordinates to fire the projectile!

avatar image GutoThomas · Jun 11, 2012 at 05:51 AM 0
Share

Nice tips! I'll try these out.

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Apply rigid body force in opposite direction of collider 1 Answer

Changing 1 parameter of rigidbody.velocity (Vector3) 2 Answers

How to apply a force after launching the player? 0 Answers

Constrain rigidbody movement to spline at high speeds / sharp curves 3 Answers

Rigidbody object intersection 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