Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I calculate an arc?

Ok, so this is for you math junkies, as I suck at math. So I create a vector3 position the part is supposed to travel to. Instead of traveling straight towards that position, I want to create an arc that goes up and lands on that position, like a catapult. How can I do this. I can only make up alternative ways like this:

waypoint = Vector3.new(0,0,0)
part = script.Parent
bp = part.BodyPosition
part.Size = Vector3.new(1,1,1)


part.Velocity = Vector3.new(0,30,0) -- The part travels up, like an arc??
wait(1)
bp.Position = waypoint -- Then it travels downwards towards the waypoint.

It works, but I want a sharp and clean arc. Not a part going up and then downwards towards the waypoint :l

3 comments

0

understand how a parabola works? x = (-b(+ or -) sqrt of [b^2 - 4ac])/2a

0

It would be nice if you used my answer to accept my answer and close the question

0

That's not exactly what I was looking for, I wanted a clean looking arc, like a half circle. Preferably calculated with an equation.

1 answer

Well what you want is something that does a mix of both. You want it to move up then bck down. Kind of like on a graph. So, something like this, (this is only a rough sketch, look into lookvectors to make it work right.)

waypoint = Vector3.new(0,0,0)

part = script.Parent

bp1 = part.BodyPosition--to keep the brick moving in the direction of the area

maxHight = 10

part.Size = Vector3.new(1,1,1)

while part.Position ~= waypoint do

bp1.MaxForce = Vector3.new(40000,0,40000) --this is so the bodyposition doesnt affect the upwards motion
bp1.P = maxHight*100 --adjust this as needed
bp1.Position = waypoint

wait()

if part.cframe.y ~= maxHight then

part.cframe = part.cframe *CFrame.new(0, 0.01, 0)

elseif part.cframe.y == maxHight then

part.cframe = part.cframe *CFrame.new(0, -0.01, 0)

end

end

This discussion is preserved as it was. New answers, comments, and votes are closed.