The video below shows a cannonball going in a diagonal / upwards direction. But all I’m merely doing is setting the cannonballs CFrame to the bazooka’s start cframe which is a part. This should automatically align the cannonball which it does do, however once I multiply the cannonballs cframe at a new angle then move it forwards it gives me this result:
local cannonball = game.ReplicatedStorage.FX.CannonBall:Clone()
cannonball.Anchored = true
cannonball.Size *= 1.25
cannonball.Parent = workspace.Effects
cannonball.CFrame = bazooka.ShotPos.CFrame * CFrame.Angles(0,math.rad(-50),0) -- this is where it messes up
game.Debris:AddItem(cannonball, 10)
while cannonball and cannonball.Parent do
cannonball.CFrame += cannonball.CFrame.LookVector * 3
task.wait()
end
I’ve tried changing the coordinates, shouldn’t it rotate based on how it’s aligned? Like if it’s facing the direction of where im pointing and going in that direction, then why doesn’t it go upwards and in that direction?
Try going off of the cannon’s look vector. Also, it could be because you do *CFrame.Angles(0,math.rad(-50),0). So, try to just set the position without the * Cframe.Angles.
local cannonball = game.ReplicatedStorage.FX.CannonBall:Clone()
cannonball.Anchored = true
cannonball.Size *= 1.25
cannonball.Parent = workspace.Effects
cannonball.CFrame = bazooka.ShotPos.CFrame
game.Debris:AddItem(cannonball, 10)
while cannonball and cannonball.Parent do
cannonball.CFrame += cannonball.CFrame.LookVector * 3
task.wait()
end
Yeah I’ve done that and it works, but I want it to go upwards that’s the problem I’m having. It’s supposed to be aligned with the direction it’s firing in, but instead it’s going to the right for some reason.
If you want it to go up, try using the math.rad in each category of the CFrame.Angles until you get the right one.
local cannonball = game.ReplicatedStorage.FX.CannonBall:Clone()
cannonball.Anchored = true
cannonball.Size *= 1.25
cannonball.Parent = workspace.Effects
cannonball.CFrame = bazooka.ShotPos.CFrame * CFrame.Angles(math.rad(-50),0,0) -- this is where it messes up
game.Debris:AddItem(cannonball, 10)
while cannonball and cannonball.Parent do
cannonball.CFrame += cannonball.CFrame.LookVector * 3
task.wait()
end
and another
local cannonball = game.ReplicatedStorage.FX.CannonBall:Clone()
cannonball.Anchored = true
cannonball.Size *= 1.25
cannonball.Parent = workspace.Effects
cannonball.CFrame = bazooka.ShotPos.CFrame * CFrame.Angles(0,0,math.rad(-50)) -- this is where it messes up
game.Debris:AddItem(cannonball, 10)
while cannonball and cannonball.Parent do
cannonball.CFrame += cannonball.CFrame.LookVector * 3
task.wait()
end