How would I apply a 'fan out' effect to a part?

Hey all, so to explain:

I’m trying to create a tool when you activate it, the player throws spikes onto the floor infront of them. However, I would like those spikes to fan out infront of him like so:

I tried messing around with Linear and Angular Velocity instances with no success… Is there another way I haven’t tried yet?

Thanks in advanced!

Do you want them to spread out evenly? Is it not letting you set the velocity at all or is it just not looking right?

Well right now, I want them to spread out further. Right now they kind of just plop in a central location

This can be done by add a RightVector, LeftVector, and/or LookVector on the parts velocity to create a spread

local FlipFlop = 0

for i = 1, 12 do -- loop for the projectiles, so if you want 12 projectiles
  local Spikes = script.Spikes:Clone()
local ShootingRight =  Character.HumanoidRootPart.CFrame.RightVector * 25 + Character.HumanoidRootPart.CFrame.LookVector * 50
local ShootingLeft =  Character.HumanoidRootPart.CFrame.RightVector * -25 + Character.HumanoidRootPart.CFrame.LookVector * 50
local ShootingStraight = Character.HumanoidRootPart.CFrame.LookVector * 50
FlipFlop += 1
-- Spike code

-- Velocity Set
if FlipFlop == 1 then
for i = 1, 50 -- Change this number for how long you want them not to fall do -- Makes it so velocity will stay consistent
Spike.AssemblyLinearVelocity = ShootingRight 
task.wait(0.02)
       end
elseif FlipFlop == 2 then
for i = 1, 50 -- Change this number for how long you want them not to fall do -- Makes it so velocity will stay consistent
Spike.AssemblyLinearVelocity = ShootingLeft
task.wait(0.02)
       end
elseif FlipFlop == 3 then
FlipFlop = 0

for i = 1, 50 -- Change this number for how long you want them not to fall do -- Makes it so velocity will stay consistent
Spike.AssemblyLinearVelocity = ShootingStraight
task.wait(0.02)
       end

    end

end

(Sorry it looks kinda messy, I wrote the code on the forums)

Why do we change the rightvector of the HRP though? Sorry just trying to understanding the script first before implementing it

We’re not chaning the rightvector but CFrame has this neat property where you can get the rightside of the part and where the part is looking upfront.

Character.HumanoidRootPart.CFrame.LookVector * 100

So what the code above does is it gets where the Character is facing by getting where the humanoidrootpart is facing and then the number it get times by is how many studs ahead from the lookvector

So the code above basiaclly says 100 studs from where the character is looking

if you put that on a parts velocity, it will launch it from where the character is looking at a speed of 100 studs per second, and the same goes for the rightvector. You can get the leftvector by just getting the opposite of the rightvector by making the number a negative.

When you add the rightvector and lookvector, it creates a diagonal velocity which creates a spread.

If you wanted just a random spread you can ignore the flipflop and



for i = 1, 12 do -- loop for the projectiles, so if you want 12 projectiles
  local Spikes = script.Spikes:Clone()
local ShootingRandom =  Character.HumanoidRootPart.CFrame.RightVector * math.random(-50,50) + Character.HumanoidRootPart.CFrame.LookVector * 50

-- Spike code

-- Velocity Set

for i = 1, 50 -- Change this number for how long you want them not to fall do -- Makes it so velocity will stay consistent
Spike.AssemblyLinearVelocity = ShootingRandon
task.wait(0.02)
       end


    end

end
1 Like

Oooohhh I see now, I’ll check that out and let you know if its the desired outcome!

Absolutely phenomenal! Thank you so much for your help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.