Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Set Pivot Point of Part or Model?

Asked by
oli414 0
6 years ago

I would like to set a pivot point for a model in Roblox Studio so that I have an offset when rotating and/or moving my model.

To further explain the scenario: Image 1 Image 2

Right now I'm putting my wall object, which I want to offset, inside of a model. This model's base part is a box with the pivot point that I want in the center.

This works for a large part except that no matter what behavior settings I use on the base part. It always ends up getting detected when I try to cast a ray. Putting it on the ignore list is not an option as I can have more than 1000 instances.

A scripted offset would not be desirable due to different wall thicknesses and/or shapes.

Is there either a better way of offsetting my wall or a way to fully ignore a part of all ray casts?

1 answer

Log in to vote
0
Answered by
oli414 0
6 years ago

Just found a solution, not quite an answer to the question but the other issue I described that would also solve my specific scenario.

You can use multiple ray casts in order to find the part that fits your criteria. In my case, I needed to find a part that had CanCollide set to true.

I now cast the ray like usual, but before actually using the result I first check if the part it hit has CanCollide set to true. If it doesn't, then I add the part to an ignore list. Then you can redo the ray cast, but with the new ignore list. You can keep on going recursively until you find the part that matches your criteria.

Code sample:

function FindSolidPartOnRay(ray, ignoreDescendantsTable, terrainCellsAreCubes, ignoreWater)
    if ignoreDescendantsTable == nil then
        ignoreDescendantsTable = {}
    end
    local part, position, normal, material = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreDescendantsTable, terrainCellsAreCubes, ignoreWater)
    if part ~= nil then
        if part.CanCollide == false then -- Check my criteria
            table.insert(ignoreDescendantsTable, part)
            part, position, normal, material = module.FindSolidPartOnRay(ray, ignoreDescendantsTable, terrainCellsAreCubes, ignoreWater)
        end
    end
    return part, position, normal, material
end
Ad

Answer this question