Should I do Line Trace on the server or client?

I have a setup whereby, if I click a certain button, the character will perform a linetrace to look for actors that it can “use”. Then. based on what it finds, it will perform different functions (for example, if it’s a food item, it’ll eat it… etc).
My question is though, should I bump the linetrace action to the server, OR, perhaps, I should do the line trace on the client, and then handle the appropriate action logic on the server?
For example, with the latter approach, I will do a line trace on the client. If I hit a food item, I will then call the Eat function, which will delegate it to the server where I will check that I do in fact have a food item, and that it’s in range, and all its properties…
How should I best go about it?

The most reliable way: do a line trace on the client to see if you are hitting something, eligible, etc. If everything is OK, then call a server function that will do the same (should pass all the tests) and do the action. Basically on a client you pre-filter, but the server has the final saying. In general, never trust the client. Server is authority and a client is just a viewer of what is going on.

1 Like