DropPod Scripting Help

Hello there.

Pictures underneath;




What it does;

So what I want it to do is detect the nearest part underneath its path, whereby it will implant a few studs lets say 5, into the blue part. I did some research, and I know I have to use Magnitude, but the Wikia page isn’t the best.


You can use raycast to get the nearest part under it.

local part = ...
local ignorelist = {}
local position = part.CFrame.p
local hit, pos, dir = workspace:FindPartOnRayWithIgnoreList(Ray.new(position, Vector3.new(0, -999, 0)), ignorelist)

local distance = (pos - position).magnitude --assuming that pos ~= nil (might want to make an if statement to handle a possible error)

You will have to loop the code above until the distance is within a certain range.

I don’t really understand what you are trying to achieve overall in your topic…

I would reccomend trying to use the code above, but I’m not sure what you mean by “implant”, I assume you mean like to make a dent into a brick, right now all we have it UnionAsync: https://developer.roblox.com/en-us/api-reference/function/BasePart/UnionAsync (that is if you want to save a lot of time and not using complex math.)

I have drop pods that fall from the sky in one of my games when an event is triggered. A ray is cast from its starting position downward to a random location on the terrain below while ignoring small structures or invisible objects. Using the results of the cast, I make the drop pod fall at a constant speed until it reaches its target position (using magnitude checks). When it does so, the control script embeds the drop pod in the terrain and creates debris depending on the material of it.

When I was first tackling the problem, however, I wanted to let the object fall naturally and whenever it touches something, it embeds itself. This was problematic since the object always embedded itself after bouncing or twisting slightly, and making the drop pod no-collide made it seem to go too far into the ground before appropriately fixing itself to the terrain.

If I had to tackle this problem again, I would probably use a custom-physics system to simulate the free fall and impact/embedding more accurately.

1 Like