How to create this split in the middle of debris

Quick backstory, im working on a module that creates these craters effects like the ones you see in combat warriors or the strongest battlegrounds. I have created the circle crater but i need guidance on how to create this effect.

here is a photo of what im trying to achieve:

The code below is the main basis to creating the rubble or crater effect.

for i = 1, (20 * Mod)/10 do
        local segments = math.random(8, 12)
        for i2 = 0, segments - 1 do
            local potCf = CF * CFrame.Angles(0, math.rad(15/segments) * i2, 0) * CFrame.new(0,0,(i * -(20 * Mod)/3) - 5)
            local result = workspace:Raycast(potCf.Position + Vector3.new(0, 3, 0), Vector3.new(0, -10, 0), params)
            if result then
                local hb = Instance.new("Part", workspace.Fx)
                hb.Anchored = true
                hb.CanCollide = cancollide
                hb.Transparency = result.Instance.Transparency
                hb.Color = result.Instance.Color
                hb.Material = result.Material
                hb.Name = "hb"
                hb.CanQuery = false
                hb.Size = Vector3.new(math.random(8,14) * 10 * Mod/segments, height, width)
                hb.CFrame = potCf
                hb.Position = result.Position - Vector3.new(0, 5, 0)
                hb.CFrame *= CFrame.Angles(math.rad(math.random(10,45)), 0, 0)
                ts:Create(
                    hb,
                    TweenInfo.new(.3, Enum.EasingStyle.Back, Enum.EasingDirection.Out),
                    {Position = hb.Position + Vector3.new(0, 3, 0)}
                ):Play()
                --if shake == true then
                --    camShake:Shake(CameraShaker.Presets.Explosion)
                --else
                --    return
                --end
                task.delay(lifetime,function()
                    ts:Create(
                        hb,
                        TweenInfo.new(.6, Enum.EasingStyle.Back, Enum.EasingDirection.In),
                        {Position = hb.Position - Vector3.new(0, 20 * Mod, 0)}
                    ):Play()
                end)
                game.Debris:AddItem(hb, lifetime + 5)
            end
        end
        wait()
    end

Ive tried to create 2 position cframes and set them to 2 opposite directions, but they end up overlapping each other no matter to what size i set it. Please if you know what i need to fix or do, anything would be helpful!

1 Like

How does the current result look like?

It looks like this weird thing


All i really need is just for there to be a split down the center of this

2 Likes

That game looks awesome so far by the way

1 Like

Thank you! Im just using the space as testing for this module, so there really isnt anything that spectacular

1 Like

Try deleting parts within an area in the middle of it?

This is the CFrame that rotates along the horizontal plane in your code:

So what you could do, the line above where that CFrame is calculated, is:

if math.rad(15/segments) * i2 < MinimumAngle then continue end

This will cause that particular iteration inside of the for i2 = 0, segments - 1 do to be skipped, leaving a gap in the middle of the deris path.

So it should be like this correct?

for i2 = 0, segments - 1 do
			if math.rad(45/segments) * i2 < 0--[[For here im still testing numbers to see what works]] then continue end
			local potCf = CF * CFrame.Angles(0, math.rad(45/segments) * i2, 0) * CFrame.new(0,0,(i * -(20 * Mod)/3) - 5)

Also just to let you know this is a module script and the CF is calculated from where the player puts the cframe, this is an example that is used for the circular crater:

mod:Crater(
			script.Parent.CFrame--[[Where the crater happens]], 
			1--[[Power | Very Sensitive]], 
			5--[[Lifetime]],
			Vector3.new(40, 40, 40), -- Size of detector
			game.ReplicatedStorage.Sphere--[[Raycast Detection]], 
			math.random(12, 12)--[[Height]], 
			math.random(10, 10)--[[Width]],
			true--[[If the camera should shake]]
		)

Yes but actually no. You hardcoded MinimumAngle to be 0 which means that there won’t be a gap along the middle.

You should instead set MinimumAngle to something like 5 degrees. Since you’re working with radians, it should be defined as the following:

local MinimumAngle = math.rad(5) -- Converting degrees to radians.

So, ive implemented this code into my module

if math.rad(15/segments) * i2 < math.rad(5) then continue end

But i get this result,


Any reason why?

Your recording perspective makes it a little more difficult to figure out the problem but I believe the issue is that I assumed that i2 went started at a negative angle, when in reality it starts at 0. Thus, the code skipped over almost half of the range. This should be compensated for.

Also, have you tried lowering the MinimumAngle variable and what affect that has?

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