Shoot Projectile in 3D from A to B
I have point A which is let's say an empty object in 3D space. Point B is the Vector3 where a raycast from camera hit the plane. I want to fire a projectile from point A to point B:
I get the hit coordonates of the raycast from the camera:
Vector3 wheretoshoot = camera.GetComponent<camerahit>().rayhitlocation;
This works and wheretoshoot has the coordonates of the point where the raycast hits.
Then I instantiate a projectile at shotPos(point A)
Rigidbody shot = Instantiate(projectile, shotPos.position, shotPos.rotation) as Rigidbody;
How do I shoot it towards point B (wheretoshoot) ? I'm using
shot.AddForce((wheretoshoot - transform.position).normalized * 1000);
the projectile is going in the right direction but passes way above point B and does not touch it.
Your answer
![](https://koobas.hobune.stream/wayback/20220612195216im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Moving cubes automatically on the y-axis 0 Answers
It lags when it collides. Help? :( 0 Answers
charactercontroller car acceleration and deceleration 0 Answers
Pick Up and Drop Script not functioning due to loophole 1 Answer
Problem with shooting time 0 Answers