Sign in to follow this  
Scarfy

"Aiming" in 3D worlds

Recommended Posts

Scarfy    122
I'm currently working on a 3rd person action game and right now the game supports a method of auto aiming where targets are automatically chosen for the player. All the player needs to do is fire and move around. However I want to add in manual aiming and although I've tried it before I never quite got it right. To determine the direction and vector for the bullets should I aiming for the horizon or reading the z value of screen pixels to determine where the shot should go? (hope that makes sense). I found the z value to work in most situations but it didn't work when transparent pixels came in to play. How should it be done? Cheers

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
cast a ray from the camera, test it against objects in the world to see where it lands
then aim the character's targeting vector at that point

yep, actually doing the math is harder than using the zbuffer thing, but lets you have better control over what objects (like transparent windows) to reject
Its more accurate in general too


Im not sure if reading the z buffer is even that fast or not, it might be a big graphics performance hit... ask a graphics expert

if not, an alternte approach might simply be to Not reander transparent stuff that causes the problem until after you get your zbuffer data... - 2pass render

Share this post


Link to post
Share on other sites
dawidjoubert    161
Quote:
Original post by Anonymous Poster
cast a ray from the camera, test it against objects in the world to see where it lands
then aim the character's targeting vector at that point

yep, actually doing the math is harder than using the zbuffer thing, but lets you have better control over what objects (like transparent windows) to reject
Its more accurate in general too


Im not sure if reading the z buffer is even that fast or not, it might be a big graphics performance hit... ask a graphics expert

if not, an alternte approach might simply be to Not reander transparent stuff that causes the problem until after you get your zbuffer data... - 2pass render


You don't need 2 passes.

Render your scene with solids only first (no particles, no non-colision stuff), do your zbuffer thingy to determine where the player is aiming and then render the rest.

This however doesn't work if the bullet has a volume because it won't give you the collision. Maths is better.

Share this post


Link to post
Share on other sites
chosendl    122
I think you should just do the math and calculate it yourself. If done correctly, it wont be as fast as the z-buffer, but the speed difference here is so small it cant possibly affect gameplay.
The upside is the amount of control you will have, will make it easier to implement all kinds of special features, like selective targeting and the same maths can be used for non human players that arent looking at a z-buffer.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this