Hi, I have been trying to create a cannon which launches physics based parts, but have run into issues with cloned part's velocities not moving them in the direction i want them to:
Current code which clearly does not work:
local model = script.Parent local function fire() local newball = workspace.Ball:Clone() newball.Parent = workspace.Storage newball.Position = model.Fire.Position newball.Velocity = model.Fire.Orientation end model.Activated:Connect(fire)
Fire is the floating green part in front of the cannon in the issue gif
So, how do i have the ball's velocity move in the direction the green part is facing (forward) regardless of orientation?
For people of the future, i worked it out.
my solution was to set the newball.Velocity to the CFrame.LookVector of the Fire part, which faces forward / at the front, and multiply it by the chosen velocity:
local velocity = 500 -- you can change this to whatever you want, higher is faster, lower is slower newball.Velocity = model.Fire.CFrame.LookVector * velocity