About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
crosshair accuracy
Author Message
abd1984 Offline
Member

Post: #1
crosshair accuracy
Hello,

We are a small developemnt team and we are testing esenthel engine and other engines in order to choose the best one for our fps game production. We bought the basic license in order to test the engine. the engine is nice and easy to start with and its stable on linux, but on mac we experienced a lot of unstability. but in all way it is a very nice engine. we are investing more before buying the full src code license.

Our question is:

We were playing with Bloody Masacre demo and we noticed that the crosshair is not acquurate at all, in fact if we look where the bullet hit, u will notice that the bullet does not hit the crosshair location at all! so we decided to implement a more advanced crosshair based on ray casting.
Here what we did:

We first backtrace a ray from the (0,0) screen coordinate to 3D pos using:
ScreenToPosDir(Vec2(0,0), pos, desiredDir);
then we align the player hand to 'desiredDir'.
Now to find the accurate crosshair position, we cast a ray of range 20 meters from the weapon position in the direction 'desiredDir', the intersection of this ray with the world is back projected to 2D using: PosToScreen(phys_hit.plane.pos, screenCoord);

the crosshair is finally drawn into screenCoord.

This technique works fine for closest distances but it quickly become inacurate if the player is looking far away (far from 20 meters). if we increase the cross hair range to bigger value ( 2000 m for ex) the aiming still works but inaccurate.

we can attach screen shots or video if the issue we are having is not clear.

any help ? does there is anyway to perfrom an accurate crosshair?

thanks
08-31-2015 04:57 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Silver Supporter

Post: #2
RE: crosshair accuracy
You could try using
SetMatrix();
VI.dot(pos);
VI.dot(phys_hit.plane.pos);VI.end
VI.line(pos,phys_hit.plane.pos);VI.end();
in draw() to see if its not your starting or end point that is being inaccurate.
(This post was last modified: 08-31-2015 06:25 PM by Zervox.)
08-31-2015 06:25 PM
Find all posts by this user Quote this message in a reply
abd1984 Offline
Member

Post: #3
RE: crosshair accuracy
Thanks Zervox smile

after debugging as u suggested, we found the problem, in fact the player was not aiming to the right nearset object. we were using PhysHitCallback, and this function does not return the collision items from the nearest to farest one. in the doc it is not mentioned how the order is returned (could be nice to improve the doc). we used instaed PhysHit which returns the closest object and now everything is going as it should be smile
08-31-2015 09:17 PM
Find all posts by this user Quote this message in a reply
Post Reply