I'm working on a tool that fires a projectile to the player's mouse position. It uses a BodyVelocity with the direction of the projectile being fired (its lookVector):

local projectileDirection = projectile.CFrame.lookVector
local bVelocity = Instance.new("BodyVelocity", projectile)
bVelocity.Velocity = projectileDirection * 300

Naturally, when fired, the projectile is released and travels in a straight line until it touches a part, at which point it is destroyed. I'm looking for a way to give the projectile a more erratic trail, somewhat like a fork of lightning.

Originally I tried having a second part, which contained the projectile's trail, orbit the part with the BodyVelocity to replicate a corkscrew effect, but, while still providing some cool results, wasn't quite the look I was going for.

I've considered it would probably be possible to map a number of randomly-generated waypoints onto the projectile's path, but am yet to find a way to put that into effect.

Would this be a viable way of doing it? And if so, I'd appreciate a point in the right direction about how to go about executing it. Or are there any other methods that may be simpler/more effective? If at all possible, I'd like to keep using Roblox's physics rather than CFraming the projectile for ease of collision detection, but this isn't vital.

Thanks.

13 comments

0

do u wanna just cast lightning?

0

cos ull prob have to do that anyway in order to achieve ur goal

0

another options would be to randomly and repeatedly rotating the projectile before locking back to the mouse's hit position

0

@TheluaBanana I'm trying to replicate an effect similar to it, but not specifically that. I mentioned the "fork of lightning" because that has a similar shape to the effect I'm trying to make.

0

@TheluaBanana I tried rotating the projectile so it orbited around a second part, if that's what you mean. That created a corkscrew movement and wasn't quite what I wanted.

0

i meant rotating the projectile itself in a random way

0

@TheluaBanana That's a bit too vague; I can't make out exactly what you're suggesting.

0

hh

0

i mean like keep randomly turning the projectile in random, at random and constantly updating the body velocity's velocity

0

up till it hits a limit before redirecting itself towards the mouse hit

0

@fredfishy Somewhat, but a sine wave has a very uniform pattern, so the projectile you've explained there has quite a rhythmic oscillation to it. It's not quite what I'm after for the same reason the as 'orbiting part' method I mentioned in my post; being that it's not erratic enough and doesn't give a sense of instability. Your post was a very interesting read, though!

0

@LukeSmasher, the maths for both is similar. Rather than choosing a consistently increasing t, choose one at random.