Jump to content
  • Advertisement

SirMt

Member
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

About SirMt

  • Rank
    Newbie

Personal Information

  • Interests
    Programming
  1. Hey Alvaro thank you for all the help!The maths is way over my head so I decided to have a go at just implementing the code -_-" this is in Unity C#: void SetLaunchAngle(float gravity, float velocity) { /* Based on this formula: Angle = atan(((v*v) +- sqrt((v*v*v*v) – g*(g*x*x+2*y*v*v)) / (g*x)) */ float x = mouseWorldPos.x - myPos.x; float y = mouseWorldPos.y - myPos.y; float v = velocity; float g = gravity; float root = v*v*v*v - g * (g* (x * x) + 2 * y * (v* v)); root = Mathf.Sqrt(root); float angle = Mathf.Atan2(v*v - root, g*x) * Mathf.Rad2Deg; PointerPivot.eulerAngles = new Vector3(0, 0, angle); } It's working alright
  2. Hey Alvaro, I read up on freefall and now understand the second equation. So... I went back and tried to solve the problem from the very beginning, one step at a time, and I'm pretty much stuck on step 1 right off the bat... :L (see image) Even when assuming there is no gravity, I don't know y and t. Oh God...
  3. In"(1/2)gt^2)^2" where does "1/2" and "^2" come from?
  4. Hey Alvaro, can you help me to understand the "(1/2)gt^2)^2" part in the second formula? So I understand that this is using pythagoras theorem and it is trying to account for the gravity, but how does it work, where does the (1/2)gt^2 comes from? Thank you! Nvm nvm, I'll watch some videos on Quadratic formula first before I bother you again.
  5. While I was searching the topic "find the angle required to shoot a projectile towards a known position with a predetermined initial velocity", I came across this equation: (https://en.wikipedia.org/wiki/Projectile_motion#Angle_required_to_hit_coordinate_.28x.2Cy.29) I'd like to try to understand this equation a bit before put it in code. Does this equation has a name that I can Google? I poked at some Physics videos on Khan Academy with no luck -------EDIT: Conclusion------- Good resources on trying to understand this formula: https://blog.forrestthewoods.com/solving-ballistic-trajectories-b0165523348c However, if you have a lot of trouble following the above tutorials, because you didn't study math and not a real programmer like me, then my advice is to just accept the formula and don't question it too much... The formula translates into something like this: Angle = atan(((v*v) + sqrt(v*v*v*v) – g*(g*x*x+2*y*v*v))) / (g*x) so just sub in the values and get the result you need yeah I was trying to brush up on HS maths and took a lot of notes, have a look if you're a hardstuck noob like me and really need some help
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!