Bullet shell ejection relative velocity

Hello! I’ve been trying for about an hour to find a way to get these bullet casings to fly in a relative direction the receiver. (receiver is basically the middle of the gun). I can’t for the life of me figure out how to get this to come out relative. Every effort I’ve made has seen the casing go either farther forward, toward my face, the complete wrong direction, etc. based on where I’m looking. I searched online for some other people doing the same stuff and tried building off their code however they must’ve had the same problems as me because the same stuff is happening using their method.

local newShell = reps.shell:Clone()
newShell.Name = "shell_"..math.random(100000,999999)
newShell.Position = receiver.Position
newShell.Velocity = Vector3.new(15,15,0)+receiver.CFrame.LookVector*8

Here’s me cloning and positioning the shell

The rotation is easy and it’s just a little farther down in the script. The main issue is having it eject perpendicular to the side of the gun every time no matter the direction you’re looking. Am I just going about this the wrong way?

2 Likes

newShell.Velocity = (receiver.CFrame.LookVector8) + (receiver.CFrame.RightVector8)

I believe you are looking for the RightVector property. It is the same as LookVector but is you know, the right side. This will also be relative to where the part is facing and I believe this is what you are looking for, just mess around with it.

1 Like

Nope, still happening…

newShell.Velocity = (receiver.CFrame.LookVector*8)+(receiver.CFrame.RightVector*8)+Vector3.new(15,15,0)

And I have played with different CFrame vectors for it but nothing seems to work!

Remove the Vector3.new(15,15,0) this is adding a constant of velocity in one singular direction.

It’s necessary. Without it, there’s no real momentum for the shell to follow. Without it, the thing just drops to the ground.

Why not add an upwards velocity then, removing the 15 on the x, so it is just Vector3.new(0, 15, 0)

Again, without those two vectors it’s always missing a movement direction I want it to have. Using only the upward direction (0,15,0) it’ll jump up before it falls straight down. I want it coming off the side and up.

newShell.Velocity = (receiver.CFrame.LookVector * 8)+(receiver.CFrame.RightVector * 8)+Vector3.new(0,15,0)

Is this expression not working? 8 studs forward, 8 studs to the right and 15 studs up?

3 Likes

Is there some way you can make the thing go farther out, quicker? Because if there is then I wouldn’t need that first 15. Can I just multiply the RightVector more?

Yep, just play around with the numbers, higher the numbers, the more velocity.