Download

dynamic croshairs

hi guys so basically i am making a dynamic crosshair for my game that changes colour and size etc to let the player know when they are targetting something. just wondering what the best approach is ?? i have a system working but it uses a sphere trace on tick event so im just worried about performance issues or if there is an easier/better way to do this. heres my setup

in my character i do a sphere trace from the player camera towards the crosshair. i used sphere because i tried linetrace first but found the line trace too narrow and often doesnt change the crosshair colour at the right time .

4c60b7cf4c1f858de32a74e7ab501772aff7b3b0.png

then i check to see if the thing the line trace hits has the tag “player” if so then it sets the lineTraceHasHitVariable to true.

then in my widget i have two functions . one to set the colour of the crosshair to green and then another to change it back to red like so.

473144e9c11a91329899a5d99569525f4c9391a5.png

here is the result