Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Test if a bullet will hit before shooting it?

$
0
0
Hello! I am making a tower defence like game. With enemys that can shoot the player. But. I want to make sure the bullet will hit before shooting. I am already raycasting. But. I am using addforce to add force to the bullet. So sometimes the ray will be casted. And it hits the object. So it shoots the bullet. But the bullet is too far away to hit the object so it falls down before hitting it. Here is how i am shooting the bullets: currentBullet.GetComponent().AddForce(transform.right * bulletSpeed); Here is an example of what is going on: The raycast hits the target (The line represents the raycast) ![![alt text][1] It looks like the bullet will hit. Because the ray hit the object. But since i'm just adding force. This happens ![alt text][3] Shown from the picture above. The bullet doesn't hit the object. What can i do to fix this? [1]: /storage/temp/91683-screenshot-17.png [3]: /storage/temp/91684-screenshot-20.png

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>