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

Need help with shell ejection from gun [?]

Asked by 5 years ago

So this has been driving me crazy, I still don't understand how to do it right.

Basically this is the current little script I use to make the shell appear to eject:

local Velocity = Instance.new("BodyVelocity", Clone)
Velocity.Velocity = Vector3.new(math.random(4,16), math.random(4,16), 0)

Nothing special and was quickly coded to save time, BUT, the problem with it is that.. this happens:

https://gyazo.com/144110334b1805ef124ff5db6a74ba10

You can clearly see that the bullet is ejecting in only one direction, which makes it look weird, how do I fix this?

2 answers

Log in to vote
1
Answered by 5 years ago

Have you considered trying

Velocity.Velocity = (Handle.CFrame - Handle.CFrame.p) * Vector3.new(math.random(4, 16), 0, 0) + Vector3.new(0, math.random(4, 16), 0)

This should convert the x axis of the velocity to the object space of the handle

Ad
Log in to vote
-2
Answered by 5 years ago

It didn't look too weird to me, maybe just tone down the velocity a little or make them different until you get a look you like.

Answer this question