Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 calebhc · Feb 14, 2013 at 02:15 AM · physicsmath

Calculate Initial Velocity to Reach Destination Based Off Time

Hello!

I'm trying to create a jump pad that can shoot an object/player to a specified location in 3D space. I know that the trajectory formulas require some initial velocity and angle but I would like to compute an initial velocity AND angle just based on how much time it should take the object to reach the destination.

Not sure if this is possible but thanks for looking!

  • Caleb

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by kOrc · Feb 14, 2013 at 04:11 AM

Let me see if I understood your question right.

Given the position of the destination with respect to the position of the jump-pad, you want to figure out an angle of launch and an initial velocity that will get your player to the destination when he triggers the jump pad, correct?

This is more of a physics and math problem, but I'll see if I can set you in the right direction at least.

First of all, in Unity, as much as possible, you want to think in terms of vectors. Solving for a vector will give you both angle and magnitudes, while thinking in terms of fewer variables. So here, you are trying to calculate the right initial velocity vector.

You sound like you are aware of the basics of trajectory formula. Just for the references, here. Don't let the partial derivatives or the calculus scare you, it just means that your life is easier because you can treat each dimension independently. Points to note:

  • There are infinite combinations of velocities and angles that can result in the trajectory you want, if you don't worry about time

  • The formula for the trajectory may not accurately represent what the Unity physics engine will execute with your computed parameters, since things like air resistance, gravity value, etc could be different.

  • The math for trajectories in 3D space is just an extension of that in 2D space.

Are you assuming no deceleration of your player once launched? I will assume you are only expecting your target to be affected by gravity. This would make calculating some parts of the initial velocity (u) actually a little simpler. You have

 p.x(t) = u.x*t

p.x(t) is the x position of the player at time t w.r.t the jump-pad. Since you know t, and you know p.x(t) (the difference in x-position between the jump-pad and the destination), so u.x is easily calculated as p.x(t)/t. You can do the exact same thing for u.z to give you p.z(t)/t. To obtain u.y, you use

 p.y(t) = u.y*t - 0.5*g.y*t*t

(g.x = g.z = 0, g.y = whatever your engine-set gravitational acceleration is) Again, since you know p.y(t) and g.y as well as t, u.y = p.y(t)/t + 0.5*g.y*t

There you go! If you have other accelerating forces involved, just modify the equations appropriately, but basically, your initial velocity vector (angles included!) will be

 [p.x/t, p.y/t + 0.5*g.y*t, p.z/t]

Hope that helped, Caleb!

Comment
Add comment · Show 2 · 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 calebhc · Feb 14, 2013 at 05:36 AM 0
Share

That's amazing! Thanks so much for the explanation. $$anonymous$$y jump pad is working great now. :) The only thing I need to figure out is why I always land a little right of the target. Is there some sort of X and Z adjustment I need to make? I'll look more into it but thanks again for the help!

avatar image calebhc · Feb 14, 2013 at 05:52 AM 0
Share

Okay, I fixed it. :) I calculated the direction vector from the player to target and then used those X and Z components to get the initial 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

10 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

Related Questions

How to make any dice have a given face(int) face up? 1 Answer

How to calculate desire angular velocity? 1 Answer

My character moves in seemingly random directions. 1 Answer

Dot Product of Vector 1 Answer

Reflection Angle - Change objects rotation 1 Answer


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