|
For example, how do i make it so the bullet goes towards the crosshair(middle of the screen) like call of duty? i dont want a crosshair in the middle of the screen for nothing... i want the bullet to go towards the middle of the crosshair even if the empty is infront of the gun( The gun is to the right of the screen) Thanks!
(comments are locked)
|
|
If you want to shoot at the middle of the screen just shoot the bullet from the camera's position in the direction of the camera's forward vector. This will guarantee you will shoot at whatever is exactly dead center of your crosshair. If I understand him, the gun is 'to the right of the screen' so does he want the bullet to emanate from the on-screen gun muzzle toward the crosshair?
Apr 11 '11 at 08:39 PM
DaveA
Yes but this doesnt look realistic a bullet just coming out of nowhere in the middle
Apr 11 '11 at 08:45 PM
niceperson87
You run into more issues if you want the offset projectile, as it will add perspective calculations for ensuring the gun itself hits the target in the crosshair. Most games fake this by using a muzzle flash and shooting an invisible projectile from the camera to the target, bullets are never seen as they travel too fast regardless.
Apr 12 '11 at 04:30 PM
Bryan 4
+1 To this, raytrace down the center of the screen and create a fake bullet from the gun. This is how most games do things and will be less annoying when players are shooting "just over" cover.
Jul 20 '12 at 04:10 PM
Muuskii
(comments are locked)
|
|
before each shot make a raycast from camera to forward and hit point returned by raycast is your bullet's target now just turn gun to this point and fire - bullet will hit center of screen independent of this point 1 meter from camera or 1 kilometer better to turn gun smoothly without firing. so keep gun always aiming object at the center of screen
(comments are locked)
|
|
What a deception! Very good solution nontheless. Try to keep your viewport as close to the gunport as possible for best results. I ended up the reverse way by adjusting the camera angle to the target distance. I give you the advice and don't try my way. The camera starts shaking everytime you peak around a corner (due to the sudden distance change). Furthermore it's a very creepy calculation thing...
(comments are locked)
|
