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
1
Question by MDarkwing · Jun 30, 2014 at 08:47 AM · movementparabola

Parabolic Movement Equation Problem?

Alrighty I have the following problem. I've been moding in Warcraft3 Map Editor for quite a long time and decided to start unity and here are parabolic equations that I've used in W3 and that worked flawlessly:

When both targets inital Y heigths are 0 (requires that both targets are grounded aka their y coordinate is 0):

 float Parabola(float h, float d, float x)
 {
     return (4 * h / d) * (d - x) * (x / d);
 }

And the function that takes the initial heights that are different ( for example y0 = 5 and y1 = 0)

 float ParabolaInitial(float y0, float y1, float h, float d, float x)
 {
    float A = (2 * (y0 + y1) - 4 * h) / (d * d);
    float B = (y1 - y0 - A * d * d) / d;

    return A * x * x + B * x + y0;
 }


where x is the localized coordinate towards target, d is the total distance between targets, h is the max height, and y0,y1 respectively height coordinates of start and end target.

This works but gives me the parabola path that is colored red, while I remember that in W3 i was getting green colored parabola path. Red look great but green is the thing that will totaly look incredible and I'm not sure where I'm making a mistake. Here is the picture: alt text

Does anyone has any other parabolic movement codes?

Thank you in advance.

EDIT:

Oh I forgot to state that the problem is that my target is moving, since I am using this formula to make some of the missiles for ranged units have an arc.

prob.jpg (41.5 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Omberone · Jun 30, 2014 at 10:24 AM

Have you had a look at http://en.wikipedia.org/wiki/Trajectory_of_a_projectile ?

You need either

  • a fixed time it will take for it to hit the ground, or

  • an initial angle of attack of the projectile, or

  • a fixed muzzle velocity

to be able to calculate the parabola accurately. As you say there are two different (four actually, but we won't bother with the two going below the ground) solutions to the equation, one that takes less time, and one that takes the longer time - with a higher arc. You seem like you know your way around math, so that wiki article should come in handy =) Should you find it difficult to implement it, come back here and let us know.

Comment
Add comment · Show 6 · 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 MDarkwing · Jun 30, 2014 at 02:05 PM 0
Share

Thank you for answer Omberone.

Problem with my parabola is following:

I don't have fixed distance, just starting distance since when unit attack the projectile is throwed and it should follow the target aka its path is dynamically changed based on targeted unit. I also don't have the predefined time at which projectile should reach target, only projectiles speed (aka distance traveled per time interval). There are two problems I see already and thats following: somehow my parabola is caluclated on hypotenuse of a triangle which is y0 y1 O (where O being the vertex bellow y0). I did in calculation drop the y0=0 and then got the distance so i get the distance between origin points not the absolute distance between mass centres of object (them being y0 and y1).

Another problem is that parabola keeps descending aka since i pass fixed distance when it reaches zero of function and target is still not reached it continues to go bellow the ground. I have fixed this problem with simple if statment condition.

I've found another formula using the angle at which you shoot projectile so I'll try using it and see what happens, but by now i get it that for full effect i need some kind of formula that dynamically calculates the height of parabola while the target moves.

Anyway thanks again, ill update if i find out something.

avatar image Omberone · Jun 30, 2014 at 03:08 PM 0
Share

Could you perhaps explain what it is you mean by "dynamically calculate the height"? You should be able to get the x,z coordinate from a target at any point in time. Do you mean that you want to do a movement prediction?

avatar image MDarkwing · Jun 30, 2014 at 03:28 PM 0
Share

Yeah I apologize, english is not my native language so I tend to be incomprehensible sometimes.

Yeah I know I can calcualte x and z at any given time problem is when if parabola is in XY coordinate system, what if x is changing over time which represents the unit moving, thats my main problem. $$anonymous$$y solution is to make it calcualte height based on the start distance then if target is not reached it just travels at that last height. Didn't test this knew formula I am currently busy with something else, as soon as I check it I'll post answer. Thanks anyway

avatar image Klarax · Jun 30, 2014 at 03:31 PM 0
Share

maybe you have seen these, but any help?

http://answers.unity3d.com/questions/377334/how-to-move-object-parabolic-projectile-path.html

avatar image MDarkwing · Jun 30, 2014 at 03:38 PM 0
Share

Well I've seen them, but they are physics based solutions, and I need hard coding solution like the top 2 equations. Not to be mislead, both equations work, I get parabolas in both cases, they are just "positioned" wrong, I need to see how can I get around that.

Show more comments

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

22 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

Related Questions

move object with parabola 0 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Making a bubble level (not a game but work tool) 1 Answer

ECS design problem 0 Answers

[Maths] How to project a curve in two axis? (Grav y + RelativeVelocity x) 4 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