Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Dragonalias · Dec 02, 2018 at 12:43 PM · physicsrigidbodyrigidbody.addforce

Launch arc with physics/rigidbody problem and on Unity's internal code

All the tutorials I've seen on this require you to use trajectory formulas (E.g. https://www.youtube.com/watch?v=iLlWirdxass&t=1353s) but that has it's own problems. Now I have to find the angle and velocity. I use Addforce with forcemode.impulse though, so I have to convert that to velocity somehow. And as far as i can see there is no easy way to find the angle (I tried vector.Angle, but that only gives between 0-180).

What I'm thinking is, doesn't Unity already have all the formulas built into the engine? When I use Addforce with forcemode: impulse, it has to calculate the trajectory of my rigidbody anyway, so why can't i access that? I tried looking in the documentation and in Unity's engine, but I can't find anything. Does anyone here know?

Comment
Add comment · Show 1
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 rrcsapp · Jan 29, 2019 at 05:24 AM 0
Share

You can still give a try to this for projectile trajectory implementation.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Captain_Pineapple · Jan 29, 2019 at 09:23 AM

Hey there,

as far as i know the short answers is sadly no.

Why: Unity does NOT calculate trajectories up front, at least not the complete trajectory. This has multiple reasons in which i do not want to dive too deeply. (If you want to learn more about this then look into system theory for machanics and dynamic systems) Basically what unity does is iterate all the physics in multiple step but just for the next frame. So there is some slight prediction there, but just for 1 frame in the future to check for collisions. Any more calculation will be just useless since the whole setup might change due to scripts. (e.g. you reset some positions, add new objects...) And useless calculations equals to bad performance here. So yes in some way the equations exist somewhere deep in the physics system but are probably not accessible to you. If you really only want to create a simple parabola for a certain object with given mass and constant gravity then you should rather just calculate this on your own.

If you need help with this feel free to ask, it's not that difficult and one can learn quite a lot when trying this :) You can also look at this question for reference. This question was about making an object always hit the same point with disregard for the launch angle and mass. So here we had to calculate a fitting "gravity". When you have the formula for whatever you need then creating a line from it is the easy part.

Comment
Add comment · Show 3 · 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 Dragonalias · Jan 29, 2019 at 07:26 PM 0
Share

No answer for almost 2 months and then suddenly there's 2. Anyway, thank you :) I'll have to check out what you and the other guy linked before I can say for sure whether I need help or if it's too much of a hastle XD Won't have time until the weekedn for that though ^^ But thanks for the explanation. that makes sense and I didn't think of that ^.^ Does your reference explain how to deal with bounce as well? Like calculating the angle a ball will have when bouncing off a wall?

avatar image Captain_Pineapple Dragonalias · Feb 04, 2019 at 12:24 PM 0
Share

Hey,

yeah i did not look at the time of creation :D it jsut popped up as "new" since there was a new comment on this.

Well the complexity of your issue depends heavily on your setup. Is there gravity involved or not? if not then this is a rather easy issue. With gravity you have to look up some calculations on how objects behave when they are thrown vertically/horizontally/angled. (which in the end is basically the same with different start conditions). It gets even trickier if you want to include spin/angular momentum into your calculation. Let me know a bit more about what you want to calculate/animate/predict and perhaps we can sort out the math needed.

avatar image Dragonalias Captain_Pineapple · Feb 04, 2019 at 06:26 PM 0
Share

Okay... So what I want to do is to predict a balls motion over distance in 2d space with gravity being a factor. I want to make a indicator, you see, so the player will be able to see the curve the ball will take, I think the biggest problem comes when walls are involved. I use physics.impulse to send the ball flying with force, and I have physics material on the walls (0.4 friction and 0.3 bounciness for now). I'm not big on math except if it's vector math which i adore XD So will probably need a lot of help if you're up for it ^^ if not then that's fine too

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

184 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Add force in slow motion 1 Answer

5.4 broke rigidbody.addForce? 0 Answers

Problems with Physics(Flipping strangely) 2 Answers

Knock down moving target ridigbody from collision. 1 Answer

Setting a RigidBody's velocity messes with my custom gravity, not sure how to proceed. 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