Issue with body velocity

Hey, so I made this fireball script using a body velocity, and it suppose to go towards the player’s mouse pointer. It works to an extent, but when I aim at the ground, it goes in a straight line, completely missing the mouse pointer. Here’s a few examples:

When I aim at the sky: https://gyazo.com/54cefae0f7f125c13e463883ac0824ef
When I aim at the ground: https://gyazo.com/d0eb6b732ccb4db999a965747c592ec6

Here’s the script:

    local bodyVelocity = Instance.new("BodyVelocity", sphere) --sphere is the fireball!!		 
    bodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
    bodyVelocity.Velocity = (mouse.Hit.p).unit*60
    character.HumanoidRootPart.CFrame = CFrame.new(character.HumanoidRootPart.Position,  mouse.Hit.p) -- makes the players character face in the direction of the mouse pointer

Let me know if that’s just what the body velocity is suppose to do. Also, that’s not the entire script, but that’s where the issue occurs.

2 Likes

I am experiencing the same issue with the body velocity, any solutions would be greatly appreciated.

2 Likes

I believe (mouse.Hit.p).Unit is measured from the origin so…

Instead of (mouse.Hit.p).Unit,
try using:-
(mouse.Hit.p - character.HumanoidRootPart.CFrame.p).Unit

4 Likes

It works now, thanks for your help!

Welcome! just for your information…
when you aim at the ground the vector (mouse.Hit.p).Unit is parallel to the horizontal plane (x-z plane because as I said before, it is measured from the origin) so it moves in a straight line

3 Likes