Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Alternative method to the rather glitchy ROBLOX Touched event?

Asked by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

I've been scripting a projectile weapon (you can think of it as a gun for purposes of this question) using Velocity and a BodyForce to make the projectile fly forwards and have a realistic gravitational effect. All my code is working well, but I've encountered a problem, especially in online mode.

Roblox's Touched event is very glitchy. At times the projectile gets deleted immediately when it hits an object, as it should, but other times it flies right on through that object (it's CanCollide false) without being deleted, especially if the part is thin.

I've been thinking I could implement a kind of raycasting system, but I'm not making a laser gun. Even if I could get the projectile to follow the path of the ray (for visual purposes) I would lose both gravity and the actual time it takes the object to fly through the air, unless you know of a way around this.

Let me know if you want any code to use for reference. Thanks in advance.

-Perci

1
Not really sure how you could do this really, besides by constantly checking distances between every instance and the bullet relative to their sizes. This is what I would probably do: Just make the gun shoot multiple backup shots all at the same time, and use a debounce to make sure only 1 counts. When that 1 hits, all the others are removed. I'm not really sure how effectively this would work, b dyler3 1510 — 9y
0
-but if you worked it out correctly, it could decrease the chances of the event not firing correctly. dyler3 1510 — 9y
0
Not sure that's the best solution but it's worth a shot if nobody else has anything better. Perci1 4988 — 9y
0
I would cast a ray in front of the bullets path, to do this you could somehow get the bullets position change and just cast a ray to that point in front of it. parkderp1 105 — 9y
View all comments (3 more)
1
I tried to post my solution but it goes above the character limit.... DigitalVeer 1473 — 9y
0
Take a look at this wiki article especially the purple target, it may help you http://wiki.roblox.com/index.php?title=Fighting_Lag User#5423 17 — 9y
0
Any way you can summarize the solution, digital? Perci1 4988 — 9y

Answer this question