Lot's of 3d game have them, too many want them. The objective is quite simple, create accurate cross hairs and draw them on the HUD. It may sound easy, but there is something I don't quite get.
Let's say I draw the cross hairs in the center of the screen as one pixel. I then line up the gun to face the center of the player's line of sight. This is no problem for things like handguns where ray-tracing can be used. But for a rocket launcher for example, things can get a bit icky. The rocket will only strike on the cross hairs if one of two scenarios occur. Either the rocket launcher being Perfectly lined up with the camera, or the player being the exact right distance from the object being struck.
This poses a problem which I have seen solved in many FPS and other games, but have failed to solve myself. How do you get accurate cross hairs for a projectile weapon like a rocket launcher?
I'm all ears.
Accurate cross hairs
-
- Posts: 194
- Joined: Thu Mar 18, 2010 3:31 am
- Contact:
Accurate cross hairs
LazerBlade
When your mind is racing, make sure it's not racing in a circle.
3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
When your mind is racing, make sure it's not racing in a circle.
3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
Try to:
1) cast a ray from camera origin towards 0,0,1 (towards the crosshair)
2) get the penetration point (if any)
3) your weapon-towards-target-dir will be the normalized(penetrPoint - weaponTipPosition); or sth alike.
1) cast a ray from camera origin towards 0,0,1 (towards the crosshair)
2) get the penetration point (if any)
3) your weapon-towards-target-dir will be the normalized(penetrPoint - weaponTipPosition); or sth alike.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
-
- Posts: 194
- Joined: Thu Mar 18, 2010 3:31 am
- Contact:
So the rotation of the gun would be changed to face the cross hairs collision point based on ray tracing? True you could change the projectile's direction, but that might occasionally lead to unrealistic flight paths. Probably a compromise would be best.
Thx!
Thx!
LazerBlade
When your mind is racing, make sure it's not racing in a circle.
3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
When your mind is racing, make sure it's not racing in a circle.
3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
-
- Posts: 194
- Joined: Thu Mar 18, 2010 3:31 am
- Contact:
Sounds good, and looks like what I see happening in MechWarrior 4 based on the projectile overshooting the cross hairs if the target has moved.
LazerBlade
When your mind is racing, make sure it's not racing in a circle.
3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
When your mind is racing, make sure it's not racing in a circle.
3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
Rotating the gun will be ugly- if you aim with the rocket launcher standing in front of a wall it may rotate that much, so it`ll cover almost the whole screen. You just shoot the projectile in the direction you get. Ducky does absolutely the same, and as he says- the clipping is minimal and somewhat what you want, plus it`s probably the best way to do it.lazerblade wrote:So the rotation of the gun would be changed to face the cross hairs collision point based on ray tracing? True you could change the projectile's direction, but that might occasionally lead to unrealistic flight paths. Probably a compromise would be best.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
-
- Posts: 194
- Joined: Thu Mar 18, 2010 3:31 am
- Contact:
Agreed.
LazerBlade
When your mind is racing, make sure it's not racing in a circle.
3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
When your mind is racing, make sure it's not racing in a circle.
3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/