0
\$\begingroup\$

I want to use a rigidbody AddForce() method on an object to launch it over from the enemy to the player, like throwing a ball at a target.

The problem is, I'm not sure how much force is required to use in the AddForce() method and it is taking too long to figure it out, and adding to that, the force would be different if I was farther away.

I found this helpful guide but it is not in 3D: https://forum.unity.com/threads/how-to-calculate-force-needed-to-jump-towards-target-point.372288/#post-2415612.

Could someone explain step by step in an easy to understand manner how to calculate the force required to get an object launched perfectly onto a target? (I'm not very good at math, haha...) Here's some images from that thread that will help illustrate the desired result:

enter image description here

enter image description here

\$\endgroup\$
  • \$\begingroup\$ This is definitely a physics and maths question first and foremost - you'll want to look up basic physics of projectile motion - this will set you on the right path. \$\endgroup\$ – Natalo77 Jun 30 at 13:53
  • \$\begingroup\$ You don't want a force for an instantaneous hop. You want an impulse or a velocity change. Don't forget to search for existing answers - we have lots of past Q&A with sample code showing how to lob a projectile at a target under various scenarios. \$\endgroup\$ – DMGregory Jun 30 at 13:55
  • \$\begingroup\$ Commenting here as I don't have 50 points, I tried using the code you gave for 3D in the linked question you gave (can't understand the math, but that's another issue for some other time), and I'm having trouble assigning the speed variable. How do I calculate the value to use for your speed variable? I put something like 10, and the projectile just launches up and falls down in the same place. \$\endgroup\$ – Jiehfeng Jun 30 at 16:39