Hi there, so I’m making a mortar/cannon that is supposed to fire the projectile in this direction:
however, instead, it makes the projectile go like this:
I used a few body movements like AngularVelocity and BodyVelocity but they didn’t really help other than making the projectile fly but in a strange direction. And I’ve also tried using tweens.
Here’s the current code (ik it’s a bit messy):
local tweenservice = game:GetService("TweenService")
local debounce = false
local explosiondebounce = false
local shooting = false
local tweeninfo = TweenInfo.new(.75, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
local tweeninfo2 = TweenInfo.new(.5, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
function Shoot()
if debounce == false then
debounce = true
local mortarshell = game.ServerStorage.ServerObjects.Models.MortarShell:Clone()
local mortarshellposition = script.Parent.MortarShellPosition
local bodyvelocity = Instance.new("BodyVelocity", mortarshell)
local bodyangularvelocity = Instance.new("BodyAngularVelocity", mortarshell)
local torqueeffect = tweenservice:Create(bodyangularvelocity, tweeninfo, {AngularVelocity = Vector3.new(0, 0, 1)})
local yaxiseffect = tweenservice:Create(bodyvelocity, tweeninfo, {Velocity = Vector3.new(0, -2, 0)})
local rotationeffect = tweenservice:Create(mortarshell, tweeninfo, {Orientation = script.Parent.TargetPoint.Orientation}) --Vector3.new(0, -90, 150)})
local positioneffect = tweenservice:Create(mortarshell, tweeninfo2, {Position = script.Parent.TargetPoint.Position})
positioneffect:Play()
torqueeffect:Play()
yaxiseffect:Play()
rotationeffect:Play()
script.Parent.MortarShellPosition.Smoke.Enabled = true
bodyangularvelocity.AngularVelocity = Vector3.new(0, 0, -1)
bodyangularvelocity.MaxTorque = Vector3.new(100000, 100000, 100000)
mortarshell.Sound:Play()
mortarshell.Position = mortarshellposition.Position
mortarshell.Orientation = mortarshellposition.Orientation
mortarshell.Parent = workspace
--[[
positioneffect:Play()
torqueeffect:Play()
yaxiseffect:Play()
rotationeffect:Play()
]]--
--wait(.15)
--debounce = false
--mortarshell.CFrame = CFrame.new(mortarshellposition.Position - Vector3.new(0, .5, 0), script.Parent.TargetPoint.Position) * CFrame.Angles(math.rad(0), math.rad(-90), math.rad(-150))
--bodyvelocity.Velocity = (script.Parent.TargetPoint.Position - mortarshellposition.Position).Unit * 500
--bodyvelocity.MaxForce = Vector3.new(100000, 100000, 100000)
--bodyvelocity:Destroy()
--mortarshell.Orientation = Vector3.new(0, -90, 150)
mortarshell.Touched:Connect(function(hit)
if hit.Name == "MortarShell" or hit:IsDescendantOf(script.Parent) then
else
if explosiondebounce == false then
explosiondebounce = true
mortarshell.Explosion:Play()
local explosion = Instance.new("Explosion", workspace)
explosion.BlastRadius = 10
explosion.BlastPressure = 2000
explosion.Position = mortarshell.Position
explosion.ExplosionType = Enum.ExplosionType.NoCraters
wait(.5)
script.Parent.MortarShellPosition.Smoke.Enabled = false
--mortarshell:Destroy()
wait(2.5)
explosiondebounce = false
end
end
end)
debounce = false
end
end
script.Parent.MortarParts.MainPart.ProximityPrompt.Triggered:Connect(function()
if shooting == false then
shooting = true
Shoot()
wait(3)
shooting = false
end
end)