How I can make one realistic gun system like this?

I use Raycasting systems, but I dont know if they are the best system I can use. I was looking for something more realistic.

Something like this:


(the game was Zeppelin Wars)

Basicly I was looking for do one system just like this (the bullet the effect etc…) I dont know if I still can use Raycasting or If I have to use one bullet with TweenService.

Any Ideas?

1 Like

Tweenservice is a bad idea, use cframe.lookat at the mouse.Hit.p or raycasts, and loop the ammo.pos += Vector3.new(0,0,1) also add a fire on the bullet if you want the effect , and connect a script.Parent.Touched on the bullet and damage the player whoever touches it then destroy the bullet , therefore you should use meshes for guns and for bullet too.

2 Likes

Using .Touched on small, fast objects such as bullets is a terrible idea. It’s not reliable enough to count all the hits and due to the fast nature of the bullet, it might just skip the object entirely and appear to go through it. You must use either segmented raycasts (if you don’t want hits to be instant) or one raycast to have proper hit detection.

3 Likes

Correct. Sometimes Fast small moving objects can cause something called “Tunneling”. Its when a small moving object skips over the thing it may potentially collide with due to the large update in position per frame.

If the fast small bullet approaches a very thin wall like glass , then if it’s going too fast , the next frame will change the position and make it skip the thin wall entirely.

@thatzenguy is right, to combat this issue, create a ray cast from its position in the previous frame to its new position in the new frame every frame. Then destroy the racist variable and set it to nol so it won’t cause memory leaks.

1 Like

Region3. Region3. Region3. Or magnitude I guess

True I tested that with speed and the hit detection was really bad with fast objects

Wait if I use raycasting systems I still can like move one small object to the position I want or the better way is using the Mouse position?

1 Like

You can use both. I just personally use mouse.Hit.p