I need help with figuring out how to shoot a sphere and hit a specific target every time no matter the distance?
Currently I’m getting the distance from the sphere to the target and adding a force (impulse) in the z direction (for the distance amount. Which works great at a specific distance but if I move the target a little further away of course when I shoot the sphere it will overshoot the target.
Any ideas on how to make it so I can shoot from any distance and hit the target every time?
Greatly appreciate any help (it doesn’t necessarily need to be coded :))
Sounds like you want to use basic kinematic equations to calculate the force and direction required to shoot the sphere. I would look up and study kinematic projectile equations.
Wow that’s some tough stuff but thank you! It seems that having just a force and distance is not enough somehow I’ll have to calculate time, velocity, speed and acceleration (-9.8).
Math is definitely not my strong suit… mind blown lol but appreciate you pointing me in the right direction I’ll post back because I can definitely see some fails on figuring out this one.
Hey @kodagames I think it won’t be too bad. There are some other tutorials on trajectories… what you want to do is not so much add a force (it CAN be done, but it’s fiddly because you have to back out the fixed time step, weight of object, etc.), but rather just set the velocity based on your calculations.
Remember also that there are actually an infinite number of launch angles at which you can fling a ball into a basket. You probably would want to choose an angle (45 is a good one to start with, unless you’re too close!!) and fix that, then calculate how fast it has to be at launch… otherwise there’s two unknowns and not enough information.
For an arbitrary solution, like if you’re standing one millimeter to the side of the basket, I think you’d have to have a heuristic that says “I will go at least X times as high as the basket,” and set the vertical component of the launch to reach that, and then select the lateral velocity based on time of flight back down to basket height, and lateral distance.
Hi Kurt,
Thanks for the response I’ll take that into consideration, so far I’m loving the kinematic equations the tutorial above does a good just of explaining things in part 1 and in part 2 he even calculates how much time it would take for a missile to catchup and destroy another object really cool stuff.
you guys are smart that’s for sure! (Way above my pay grade lol).