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

make a working shell that fires into the air and lands in specific location?

Asked by 5 years ago

i dont know how to explain the title, but i'm trying to make a very simple concept and i'm getting very broad results because i'm terrible at math. i basically want to make a cannon that fires a ball straight into the air and land into the desired position. i'm using bodyvelocities and a lot of cframe and magnitude but so far nothing has worked for me. i don't know what code to provide you with because it's extremely ugly and hard for even me to understand, but i will provide what i have that launches the ball into the air, redirecting it to a target position

local shell = Instance.new('Part',workspace)
        shell.Anchored = false
        shell.CanCollide = false
        shell.CFrame = barrel.CFrame -- < you can ignore the "barrel" stuff
        shell.Size = Vector3.new(1,1,1)
        local mesh = Instance.new('SpecialMesh',shell)
        mesh.MeshType = 'Sphere'
        local velocity = Instance.new('BodyVelocity',shell)
        velocity.MaxForce = Vector3.new(999,999,999)*math.huge
        velocity.Velocity = Vector3.new(0,90,0)
-- i make it wait .5 seconds and then redirects it to a new position
wait(.5)
local dir = CFrame.new(shell.Position,part.Position).lookVector*90
            velocity.Velocity = dir
-- so far all my results have been the shell going right over the targets head, or going in the completely wrong direction

if any of the helpful people in this community could provide me with some information and techniques on how to do this, that would be great

Answer this question