Is Player Looking 'Generally' at an Item?

Опубликовано: 07 Август 2026
на канале: GGameDev
233
3

I have had bad experiences playing some games, especially games which were made for pc and then (poorly) ported to console (I'm looking at you Myst, on Xbox One.)
It is just poor usability to force the player to have to focus on getting a tiny cursor or crosshair perfectly aligned with various onscreen objects, especially when some of those object are only a few pixels in width.
(Unless of course you are making a game called 'Super-fun-time-align-tiny-crosshairs-with-variety-of-single-digit-pixel-width-objects', in which case, go for it!)
Anyway, I tried a variety of methods to get around this, I tried calculating normalized forward vector angle of rotation to target... but that felt off, and the results varied greatly with the player's distance from the target. Plus it didnt give me the chance to 'fine tune' it for specific objects.
So in the end, I went for a fairly simple approach using a basic collison object (sphere/box/capsule) to test if the player is 'in range', and then a forward vector line trace to test for collision with a 'disc' object automatically created in the pickup class.
Not only does this method work pretty well, it also gives us the opportunity to 'tweak' things on a per item basic; radius of the disc, offset from the item towards the player, etc.