It’s rather self-explanatory. I’m wanting to make a similar wood-cutting system to LT2 (Lumber Tycoon 2), but I’ve found little to no documentation on how to do so.
I find how the tree actually splits in half, and how you detect the height a player is clicking on and chopping is the most confusing and obscure bits.
You’re likely not going to get any replies topic because forummers don’t tend to respond to these kind of posts as you aren’t asking for any specific help or solutions, try to keep looking around for articles until you find one. You should find one if you keep looking.
You can make it a bit easier if you decide that branches will always be oriented in one specific way, namely so that their Z axis is always the length-wise direction (any axis works, but Z is the natural choice).
That way you can simply convert any 3D point, e.g. mouse.Hit.p, to a point relative to the branch CFrame and finally take the Z coordinate. E.g.:
function projectPointOntoPartLengthAxis(point: Vector3, part: PVInstance): Vector3
return part.CFrame.LookVector * part.CFrame:PointToObjectSpace(point).Z
end
As for chopping a branch at the right location, it might be more useful to determine “how far along the branch the point is”, either in absolute terms (studs) or relative terms (a percentage/fraction of the total length):
function absolutePointProgressAlongPartAxis(Vector3, part: PVInstance): Vector3
return part.CFrame:PointToObjectSpace(point).Z
end
function relativePointProgressAlongPartAxis(Vector3, part: PVInstance): Vector3
return part.CFrame:PointToObjectSpace(point).Z / part.Size.Z
end