Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Client Side Hit registration

A topic by CodeCrunchers created Aug 09, 2023 Views: 66
Viewing posts 1 to 1
Developer

When firing a weapon, the Sever was able to appropriately hit the target but the Client was unable to shoot in the desired direction. This was frustrating for the user since their inputs would not be registered as valid hits when playing and could not kill any of the AI.

Upon further investigation, I noticed the line trace that is used to determine if a hit is valid was using the proper start point, but the end point was location on the Character's Camera forward vector. I knew this had to be the issue, so I started testing if it was server or client side. The server's vector was properly updated but the clients was staying zeroed out. After a series of failed attempts at replicating the proper vector, I remember that the APawn class has a method called GetBaseAimRotation(). For player controlled pawns, this will return the center camera transform which is almost what we needed. I converted it to use Vector.X which should simulate the same Forward Vector and sure enough, the proper trace had been cast for both server and client players.