I understand that for many of you it will be silly or simple question, but I asked anyway:)
What do you use (or maybe what used for game developing) to interact with objects: linetrace (or another trace) or overlap event?
m understand: the linetrace depend on "event tick", and it will negativly affect to game FPS (correct me if im wrong);
but for the overlap event I need to create collision for all objetcs that i need (and it can be many-many objects).
So, what will be lighter for the engine and what do you use in your tasks?
It seems to me that line trace would be more effecient than overlap since a line trace only happens on the frame it is cast. Where overlap needs to be checked every frame.
Line trace is not dependent on tick. For shooting you would only cast a line trace when the user fires the weapon. To detect what the user is looking at you can cast a line trace ever 0.1f seconds or so.
You are going to end up using both for different needs. I use line traces for weapons firing and interacting with usable objects in the world. But I also use Overlap events for things like health pick-ups and triggering cutscenes.
Any function that you call yourself (“run this query against the world”) will be less efficient than a callback you get from the physics system itself.
So, overlap events happen because the physics system, when doing work it would typically already do anyway, detects the overlap. This is fairly cheap.
If you, inside Tick, call “trace this line” or “test this sphere” or whatever, that’s calling back into the physics system, asking it to do more work.
Now, for things you do when the user does something – find a trace to the target for a fired bullet; find the right place to drop an item out of inventory; or similar; the difference won’t matter, and you should use the method that seems to give you the best results (objects goes to the best place.)
For things you really want tested every frame, you’re typically better off with overlap events.
thanks a lot man, you directed me