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

Making a cannon, How can I have the cannonball shoot in the direction of the cannon?

Asked by 6 years ago
Edited 6 years ago
partstore = game.ServerStorage.CannonBall
workspace.Launch.CanCollide = false
pressed = false
turningangle = workspace.Launch.Orientation
function shoot()
if pressed == false then
local storepart = partstore:Clone()
storepart.Parent = workspace
storepart.Position = workspace.Launch.Position
storepart.Orientation = workspace.Launch.Orientation
storepart.Velocity = Vector3.new(-200,0,0)
pressed = true
wait(5)
workspace.CannonBall:Destroy()
pressed = false
end
end

game.Workspace.Launch.ClickDetector.MouseClick:connect(shoot)

~~~~~~ I know the script is really messy right now but I'm planning to tidy it once the basic functionality is sorted. I'm trying to get the storepart.velocity to shoot in the direction the cannon is pointed at around 200 studs, I know how to get it to shoot at a specific angle, but I don't know how to get it to shoot in the constantly changing rotational direction of the cannon.

0
Use the code block, scroll over the lua sign in edit. Next to where all the options are like italics etc superhudhayfa 39 — 6y
0
Thanks, I thought that might have been it but when it just came up with a bunch of tildas I decided to just leave it as is. :P JackMills 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

If I were you I would try CFrame, because if you connect them with CFrame, the StorePart's Rotation will be the same as the Launch rotation.

0
Would that not just change the rotation of the shape while the velocity direction remains the same, therefore causing the direction of the shot to remain the same? JackMills 0 — 6y
Ad

Answer this question