I am making a hockey game, and I when I shoot the puck it goes either along the floor or too high. Sometimes it’ll go in the wrong direction, I am trying to get the puck to go almost directly where the mouse is located, but without it going way too fast. Any ideas?
HitEvent:FireServer(Stick, Mouse.Hit.Position * Vector3.new(1,2,1))
local HitEvent = game.ReplicatedStorage.PuckHitEvent
HitEvent.OnServerEvent:Connect(function(Player, Stick, MousePosition)
if Stick:FindFirstChild('PuckWeld') then
local Puck = Stick.Puck
local Direction = MousePosition - Puck.Position
local Distance = math.min(Direction.Magnitude, 20)
local Force = Direction.Unit * Distance
Puck.Parent = workspace
Stick.PuckWeld:Destroy()
Puck:ApplyImpulse(Force)
Stick.HitSound:Play()
end
end)
Code ^^^
Edit: I know now that multiplying the Y axis is what causing the problem in the video, although, I’m still wondering the method of making a more linear path towards the players mouse when using apply impulse (without increasing the force)