Hello everyone. I am currently working on a survival game that draws similarities from Rust and Unturned.
I’m currently trying to get bullets to shoot quite straight, but they don’t seem to be working perfectly.
The system I use for getting the bullet’s cframe is an attachment within the gun model called “bspawn”, which just tells my event where the CFrame is. The bullet spawns from the CFrame point, and it moves using this code every heartbeat : Bullet.Projectile.CFrame = Bullet.Projectile.CFrame*(CFrame.new(0,0,-Bullet.CurrentSpeed))
What seems to happen though, is that the bullet somehow goes down.
For anyone wondering, the bspawn point is the tip of the rear sight.
Does anyone know a way to eliminate the unexplained offset? Any help and or tips to improve anything would be greatly appreciated, as I have been accustomed to things completely unrelated to these types of things for the past few years. Thanks in advance.
Please inform me on how I can improve my posts, First post here.
I’ve noticed a few things that seem weird to me on this.
Is the Bullet.CurrentSpeed an IntValue? If so, use Bullet.CurrentSpeed.Value.
The reason your bullet goes down may be because it’s not following the LookVector. If you don’t know what LookVectors are, they are like directions of a CFrame. You have LookVector, RightVector, and UpVector. Try using Bullet.Projectile.CFrame = Bullet.Projectile.CFrame + (Bullet.Projectile.CFrame.LookVector * Bullet.CurrentSpeed).
I hope I helped.
Currentspeed is just an integer. Dictates how fast or slow it goes, and your code basically got it, but I tried that and that still had the same effect. Thank you for your effort though
Just for now, I’ve tried moving my bspawn attachment. Still really doesn’t do much, I did use your code sample, but it basically did the exact same thing it was doing as the old line. My old solution was using body movers, but that went horribly haha
aside from the code that actually moves it, here is the spawn code
I think this is because the mouth of the gun is inevitably lower than the sight, so it’s impossible to match up exactly. This is actually a problem with real life guns. What some games do is they cast a ray from the sights then have the bullet head there from a velocity to maintain maximum accuracy. Just my theory though.
I’d imagine you being correct, I’ve been messing around with my current speed var, setting it really low to see the exact movement. It seems to just go lower by itself, even though everything is centered. I’ll try and do that and see what happens.