So I have this fireball spell, and it works, however the direction of the body velocities are inconsistent and change based on a players rotation. Sometimes as shown in the video a fireball doesn’t even move.
CODE
local maxForce = Vector3.new(1e6, 1e6, 1e6)
local lookVector = character.HumanoidRootPart.CFrame.LookVector
local bv1 = Instance.new("BodyVelocity")
bv1.MaxForce = maxForce
bv1.Velocity = (lookVector) * force
local bv2 = Instance.new("BodyVelocity")
bv2.MaxForce = maxForce
bv2.Velocity = (lookVector - Vector3.new(0, 0, 1)) * force
local bv3 = Instance.new("BodyVelocity")
bv3.MaxForce = maxForce
bv3.Velocity = (lookVector + Vector3.new(0, 0, 1)) * force
local bv4 = Instance.new("BodyVelocity")
bv4.MaxForce = maxForce
bv4.Velocity = (lookVector + Vector3.new(0, 0, 1.5)) * force
local bv5 = Instance.new("BodyVelocity")
bv5.MaxForce = maxForce
bv5.Velocity = (lookVector - Vector3.new(0, 0, 1.5)) * force
Seems like this is a problem caused by the direction vector not being relative to the humanoid root part. Personally I recommend manipulating rotating the humanoid root part along the UpVector to get the new direction:
Consequently, because we are rotating the look vector along the UpVector even if the character gets knocked down it will still cast the spell in front of the chest.
--Angle in degrees cuz degrees are easier to work with
local angle = 25
local upDirection = character.HumanoidRootPart.CFrame.UpVector
local rotateCFrameAlongHumanoidAxis = CFrame.fromAxisAngle(upDirection,math.rad(angle))
local newCFrame2 = character.HumanoidRootPart.CFrame * rotateCFrameAlongYAxis
local fireBallDirection2 = newCFrame2.LookVector
bv2.Velocity = fireBallDirection2 * force
This is the operation of the CFrame look vector illustrated from the top of the character always(Via the UpVector).
As seen the angle spread will always stay the same as it’s being rotated the same amount from the look vector.
Here is what you were doing before for bv3:
bv3.Velocity = (lookVector + Vector3.new(0, 0, 1)) * force
The red arrow in the diagram is the look vector and the black arrow is Vector3.new(0, 0, 1)
Would work but then when you start rotating it player towards the z axis the vector triangle would change and the angle of the spread would be change relative to the red look vector.
Very interesting solution, but kinda hard for me to understand, so I just rotated the particles part.
CODE
fireburst2.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(3, 0, -6) * CFrame.Angles(0, math.rad(-30), 0)
-- when the time comes to apply the force
local bv2 = Instance.new("BodyVelocity")
bv2.MaxForce = maxForce
bv2.Velocity = (fireburst2.CFrame.LookVector) * force
-- set the parents
bv2.Parent = fireburst2
fireburst2.Parent = workspace
-- optional debris (you'll probably use this though.)
Debris:AddItem(fireburst2, 6)
Thanks for the insight on Vectors though, I’ll refer to this whenever I need to refresh my mind on Vectors and how they work.