Quantcast
Channel: Questions in topic: "gun"
Viewing all articles
Browse latest Browse all 592

Firing a bullet doesn't work properly in the bottom half of the screen

$
0
0
I'm using a raycast to guide a bullet trajectory, and it works really well in the top half of the screen. But anything below that fires straight out for some reason. Here is my code: if (Input.GetButtonDown ("Fire")) { if (canFire == true) { if (currentAmmo > 0) { currentAmmo = currentAmmo - 1; Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition); ammoType = Instantiate(ammoType, transform.position, Quaternion.identity) as GameObject; ammoType.GetComponent().AddForce(ray.direction * shotPower, ForceMode.VelocityChange); } The big problem I'm having is that I want short/crawling enemies on the ground. This is for a lightgun style game. In this screenshot I'm shoting along the bottom edge of the screen, and the bullet starts in the right position however goes straight out instead of shooting downwards. ![alt text][1] [1]: /storage/temp/55792-screenshot-2015-10-08-134833.jpg

Viewing all articles
Browse latest Browse all 592

Trending Articles



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