i guys, right now i am doing some visuals for my combat, inspired on Soul shatters
and i wonder, how could i spawn some parts (slash vfx) on a 360 angle, and then set them on random positions, ofcourse i don’t want it to be a circle, neccesary, but yeah, that and make it also look at the opposite direction of the target part (no one will notice this, but it can be useful), then finally tween the slash part to his LookVector and change his size to 0
currently i am stuck at the spawning and setting the rotation and position, how would i go about this?
Currently, i only got the system right here
task.wait(.1)
local targetPart = workspace:WaitForChild("ttd")
local amount = 15
local slash = game.ReplicatedStorage.slasheffect
local function getXAndZPositions(angle,radius)
local x = math.cos(angle) * radius
local z = math.sin(angle) * radius
return x, z
end
local slashParts = {}
for i = 1, amount do
table.insert(slashParts, slash:Clone())
end
task.wait(.1)
for i, part in pairs(slashParts) do
-- set part positions/rotations/orientation
part.Parent = workspace
end
Maybe this is just very basic, i wish i hadn’t leave school so early
This isn’t perfectly random considering that the parts may spawn slightly more often with some orientations than others but what I would do to set random rotation for a part would be to do this: yourPart.CFrame = CFrame.new(yourPart.Position) * CFrame.fromEulerAnglesXYZ(math.rad(math.random(0, 360)), math.rad(math.random(0, 360)), math.rad(math.random(0, 360)))
As for the rest, I don’t really understand your problem. A video reference of something similar would help.
It looks good so far, i testes it, this is the result
do you know how i could add a distance?, so the parts won’t be near
code :
for i, part in pairs(slashParts) do
part.CFrame = CFrame.new(targetPart.Position) * CFrame.fromEulerAnglesXYZ(math.rad(math.random(0, 360)), math.rad(math.random(0, 360)), math.rad(math.random(0, 360)))
part.Parent = workspace
end
Alright so i did more tests and i did this effect, not the one i want (but if there is nothing i can do, then i will use this one)
this is the code
for i, part in pairs(slashParts) do
part.CFrame = CFrame.new(targetPart.Position) * CFrame.fromEulerAnglesXYZ(math.rad(math.random(0, 360)), math.rad(math.random(0, 360)), math.rad(math.random(0, 360)))
part.Parent = workspace
local tween = game:GetService("TweenService"):Create(part,TweenInfo.new(0.55),{Position = part.Position + part.CFrame.LookVector * 12})
local tween2 = game:GetService("TweenService"):Create(part,TweenInfo.new(0.5),{Transparency = 1})
local d = math.random(1,2)
if d == 1 then
part.Color = Color3.fromRGB(255, 255, 255)
elseif d == 2 then
part.Color = Color3.fromRGB(15, 255, 247)
end
tween:Play()
--tween2:Play()
end
I wonder why it doesn’t works since i am using the lookvector, maybe because there’s so many parts… and i can’t change the lookvector of only one , if anyone got a idea on how to fix this or any other possible solution please tell me!
I’m going to be completely honest, I don’t think those are parts. They’re bright, but don’t give off that weird bloom effect that neon does. Have a look at particle emitters instead, I have a feeling it’ll be much easier for you.
If you still want to use parts, I’d be interested in why. I find messing with welds and transforms is too much for something like this.
You can use NextUnitVector() to generate a random direction,
Example code:
local Position = Vector3.new(0, 10, 0) -- The position of where the parts will spawn from.
local Distance = 5 -- The distance from the spawn position.
for I = 1, 10, 1 do
local RandomDirection = Random.new():NextUnitVector() * Distance -- The random direction generated.
local NewPart = Instance.new("Part", game.Workspace)
NewPart.Anchored = true
NewPart.Color = Color3.new(1, 0, 0)
NewPart.Size = Vector3.new(0.25, 0.25, 1)
NewPart.CFrame = CFrame.lookAt(Position, Position + RandomDirection)
NewPart.Position = Position + RandomDirection
end
Why don’t you just use particles? It will make everything way easier and you will also have more accuracy. Your references also feature games that use particles, not parts
I think he wants to use parts so he can have more controls of the effects, and to also have like a 3D effect I think. (Sorry I don’t know a lot about effects.)
As @SirKhalidBlox said, I need it to be 3d for that feeling and also, because, I got to a point where particles can cause lag, I know parts do too, but Not like that when created on the client, so i’ll just stick with parts visuals instead of particles one, But i will make sure to use the method you offered too!
And also, you may be correct!, but i know the game i am based on uses Part and the sphere mesh for them
You can multiply the random direction by 2 to get a farther position,
Updated code:
local Position = Vector3.new(0, 10, 0) -- The position of where the parts will spawn from.
local Distance = 5 -- The distance from the spawn position.
for I = 1, 10, 1 do
local RandomDirection = Random.new():NextUnitVector() * Distance -- The random direction generated.
local TweenDirection = RandomDirection * 2
local NewPart = Instance.new("Part", game.Workspace)
NewPart.Anchored = true
NewPart.Color = Color3.new(1, 0, 0)
NewPart.Size = Vector3.new(0.25, 0.25, 1)
NewPart.CFrame = CFrame.lookAt(Position, Position + RandomDirection)
NewPart.Position = Position + RandomDirection
game.TweenService:Create(NewPart, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In), {
Position = Position + TweenDirection;
}):Play()
end