How to make an airdrop (ideas)

Hello! So I’m planning on making an AirDrop system, but I was wondering, I will make airdrops, with RayPart, so, I will make them spawn randomly within a zone, and I will check if the ray.material is grass or concrete, but, I don’t remember how do I make a ray, I want a ray to go facing down like this:
image
How do I make a Ray goes straight down?

Another question, do you think I should tween the aidrop or add a BodyMover, or BodyVelocity to make it goes down?

https://gyazo.com/88b6a452f25d818cc60f014ee5cc6a33
I think I will use BodyVelocity, and with the raycast check the distance and if the distance is close then well, I remove bodyvelocity

2 Likes

To make a ray go down, do

local new_ray = Ray.new(origin, -cf.UpVector*distance)

As for the last question, do whatever you want. Though air drops usually land freely, not to a fixed position.

Question, Do I need to use a loop, and how do I calculate distance, what will be origin? the start cframe ?and -cf CF would be the CFrame we want to go?

What is the loop for. If you are looking to fire it at certain times in your game use a bindable event. And the distance can be anything you want. Ten, twenty, one hundred, one thousand, whatever you want. Since UpVector is a direction, you negate it first because UpVector is the top direction, then you have a “DownVector” by negating it. Multiplying it by an arbitrary number distance will make it go distance studs from the cf. And cf is whatever CFrame.

Ok, distnce is a Vector3 or a CFrame? (sorry , :confused: )

Distance is a Vector3 position.

1 Like

Alright, so about, origin it’s where it starts? and what do you mean CF is whatever cframe?

Origin starts wherever you want. I don’t know how your game is structured so I can’t help you further about where. It might be a good idea for the origin to be cf.Position so you can get the position and down direction of the CFrame position where it should start

Try using find part on ray, make the ray’s origin the middle of it, the ray target Crate.Position - 1000 on y axis with vector3 and then tween it making the tween goals postion of the y axis being + .5 * total height above the find part on ray position.

Alright, so like this?

local new_ray = Ray.new(script.Parent.Part.Position, -script.Parent.Part.CFrame.UpVector*workspace.Baseplate.Position)
local hit,position = workspace:FindPartOnRayWithIgnoreList(new_ray, {script.Parent["Metal Crate"], script.Parent.Part},false, false)
if hit then
	print(hit.Name)
end

It’s not printing anything even when there’s a part down

Why are you multiplying by a Vector3? You should multiply by a number which is the distance you want it to go down to.

Code:

local part = script.Parent
local new_ray = Ray.new(part.Position, -part.CFrame.UpVector*40)

local part, position = game:GetService("Workspace"):FindPartOnRay(new_ray)
print(part, position)

Output:

  Baseplate 53, 0, -10

The baseplate was within 40 studs of the direction.

Ok so how do I calculate the distance to an object down?

Try what I said above, it should work.

Ok so, I made this

while wait() do

local new_ray = Ray.new(script.Parent.Part.Position, -script.Parent.Part.CFrame.UpVector*script.Parent["Metal Crate"].Size.Y/2)

local hit,position = workspace:FindPartOnRayWithIgnoreList(new_ray, {script.Parent["Metal Crate"], script.Parent.Part},false, false)

if hit then

print(hit.Name)

script.Parent["Metal Crate"].BodyVelocity:Destroy()

script.Parent["Metal Crate"].Anchored = true

break

end

end

Do you think it would lag if there’s like 5 airdrops?

What happened to the tweening part? It’s not going to move at all with that script, and it won’t lag with only 5 parts moving. Also you need to make it choose a random position in the sky before the ray is created, less than 1000 studs in the sky, or make the ray bigger.

Yes, I’m using BodyVelocity 30chars

I’m not familiar with body velocity, so I can’t help if you do it that way.