Hi, I have a tree that you can cut down in my game. Once it hits the ground I want it to split into 3 logs. I have that done except for the math. I don’t know how to split it into 3 and keep the rotation. How would I go about this?
The only way I can think of goes like this:
-
The tree falls and hits the ground.
-
You save the rotation of the tree (if it’s a part) or a specific part of the tree (if it’s a model).
-
You have a log that you can store in ReplicatedStorage or similar.
-
You destroy the tree model via code.
-
You clone the log 3 times and change their positions to take the shape of the original tree.
-
You rotate them to match the original rotation.
2 Likes
for _, Tree in pairs(workspace:GetChildren()) do
if Tree:IsA("BasePart") and Tree.Name == "Tree" then
local Split = 3
for i = 1, Split do
local p = Tree:Clone()
p.Size = Vector3.new(Tree.Size.X/Split, p.Size.Y, p.Size.Z)
p.CFrame = Tree.CFrame - Tree.CFrame.RightVector*Tree.Size.X/2 + Tree.CFrame.RightVector*p.Size.X*i - Tree.CFrame.RightVector*p.Size.X/2
p.Parent = script.Parent
p.Anchored = false
end
Tree:Destroy()
end
end
TreeSlice.rbxl (33.3 KB)
2 Likes