LookVector Being Inaccurate

Hi all,

I’m currently working on a football game. When the player kicks the ball, the ball should go where the camera is facing. So when I’m not moving, the shooting goes as intended. However, when I shoot while moving, the accuracy of LookVector is very questionable.

Why does the ball not go in the same direction as the gray trajectory estimation line? How can I solve this issue?

Code:

local lookVector = game.Workspace.CurrentCamera.CFrame.LookVector 
local force = Vector3.new(lookVector.X, 0, lookVector.Z).Unit * power + Vector3.new(0,highPower,0)
ball:ApplyImpulse(ball:GetMass() * force)

Thanks in advance.

1 Like

It seems the ball is inheriting the velocity of the player. Remove the .Unit from the force a nd the lookvector is already a unit vector and instead of cameras look vector use the humanoidrootpart’s lookvector.

2 Likes

The ball is still inheriting the velocity of the player. That did not make a difference.

Instead of ApplyImpulse here I would just explicitly set the AssemblyLinearVelocity which would remove any velocity inheritance issue you’re having. Also, you don’t need to take mass into account with AssemblyLinearVelocity, mass being considered is one of the big selling points of ApplyImpulse.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.