Hi, i’ve been having quite a bit of trouble today working out VectorForce and using it for plane weapons. The premise is to create a bullet and have it travel the direction the plane is moving, with no relation to the mouse, when the player clicks. However, my current progress is some laggy amalgamation of ballistics where the bullets spawn in and just spin randomly while flying to their destination.
local ship = blasters.Parent --blasters is the front of the gun the bullets shoot from
local laserA = FIGHTER_PARTS:WaitForChild("Laser"):Clone()
local leftLaserVelocity = Instance.new("VectorForce")
leftLaserVelocity.Enabled = false
leftLaserVelocity.Parent = laserA
leftLaserVelocity.Force = (ship.BlasterA.CFrame.lookVector * 10000)
leftLaserVelocity.RelativeTo = Enum.ActuatorRelativeTo.World
leftLaserVelocity.Attachment0 = laserA:WaitForChild("Attachment")
laserA.CFrame = (ship.BlasterA.CFrame + ship.BlasterA.CFrame.lookVector * 10) * CFrame.Angles(0,math.rad(90), 0) --rotate by 90deg to travel like a bullet instead of long-ways
leftLaserVelocity.Enabled = true
laserA.Parent = game:GetService("Workspace")
I don’t have much experience with the Physics constraints; however, I did try using Linear Velocity and failed. The example plane I was using is using BodyVelocity which is deprecated, so Linear Velocity seemed appealing but worked even less.
I tried creating a Ray from the ‘blasters’ object to blasters.CFrame.LookVector * 1000
and assigning that as the force*int but that also proved to be unreliable.
Thanks in advance!