Need Help Understanding Touch Events

I want to acheive touch event consistency in projectiles.
There is an early reaction from server each time I use touchevents but in other games they exactly do like projectile energy balls explode when the moment they hit somewhere

how can I achieve that? How to use touchevent properly?

thanks in advance

I recommend not using Touched events at all for projectiles :sweat_smile:. They just aren’t reliable since Touched is physics-based, and a lot of things, like framerate, object shapes, or network lag, can cause it to trigger early or late. I recommend using Raycasting because it doesn’t have issues like that and is more consistent.

Raycast Documentation

The difference you notice is how it’s handled. There is always going to be time between the server doing something and the client getting the message telling it about it. Most of the time you need to use strategies to hide latency. This would be something like firing the projectile early and just tweening on the client. Ultimately you should trust the server so there will always be some delays. A rule of thumb most people follow is damage and stats done on server, visuals on client. Working back from there you can solve ways to reduce visible latency or look into models for handling latency that people already describe.

I had the same issue as you before. I think this might help: Very laggy/delayed movement

Not actually possible.. you’re looking for Raycast.

Thanks for the replies
raycasting seems so complicated to me
do you think it can be handled in short time?

Touch events are NOT gonna work with moving parts.

the most common way is using raycast and then using a formula to tween the projectile at a certain speed, in the exact time it needs to hit the part. however with moving parts this is not gonna work as expected.

another way is using a trajectory, and then do constant checks (with raycasts or partsInRadious), and with some tweaks this can be optimized to handle many projectiles at the same time, but is very difficult if not done the first time, and sometimes math and time is required for this.

It’s not that complicated. It has a starting point and an ending point (likely the mouse position in this case). A line (ray) goes from one point to the other and can return what it hits. In many cases, you can add a whitelist of things you don’t want returned. Try a few examples, you’ll get it. Don’t let it intimidate you; it just sounds complicated. It’s actually the go-to method in many cases and well worth learning.

Yes I think it’s not too bad because ChatGPT can walk you through all of it. I recommend making the rays visible when trying it for the first time so you can understand how it works, but it really narrows down to how people learn best. For visual learners my idea is great :slightly_smiling_face: