I’m creating a gun system, currently i use rays to define the part trajectory, and i tween the part to the destination, however, i’m trying to implement a way to know if the trajectory gets blocked or something.
For example, if a part blocks the trajectory, and the bullet touches that part, then it would register the hit.
I’m trying to use a Touched event for that, the only problem is that the touched event only works with unanchored parts, if you need the script you can ask me.
An example here, i made it so if the part detects a hit, it would turn red:
The results with the unanchored part:
The results with the anchored part:
I thought about updating the ray constantly, but the problem is that i would need to rescript the entire gun system, and another option would be using Region3, but i’m not sure if constantly updating the Region3 would be efficient.
Any help is appreciated. As i don’t know what should i do. Thanks for reading.
yah… This would be a good time to use raycasting, raycasting to the next position of where the bullet goes. (You wouldn’t use tweenservice since you don’t know when tween actually updates the property), you would need some sort of loop.
With raycasting I could handle 600 to 800 bullets a second, but if you aren’t doing a mad bullet game like me then region3 isn’t going to be that laggy. Unless if your willing to rewrite your whole gun system stick with region3. OR EVEN BETTER :GetTouchingParts()