So I’m creating a hockey game. I’m not going to get to in to it but basically you’re able to grab the puck, hold down the mouse for power, and shoot. To shoot the puck I’m giving it velocity, the problem is it that the puck is going to high in the air, even if I give it 0 y velocity it somehow finds it self getting random y velocity and going straight up, how can I counter this?
script.Parent.ShotEvent.OnServerEvent:Connect(function(player,power,pos)
print(pos)
script.Parent.Values.PuckHolder.Value = false
local np = game.ServerStorage.Puck:Clone()
np.Name = "Puck"
np.Parent = workspace
np.Position = script.Parent.Puck.Position
np.Anchored = true
np.Script.Disabled = true
script.Parent.Puck.Transparency = 1
local z = (pos.Z - np.Position.Z) * 50
local x = (pos.X - np.Position.X) * 50
local y = (power * 0)
np.Anchored = false
np.AssemblyAngularVelocity = Vector3.new(x,y,z)
wait(1)
np.Script.Disabled = false
end)
1 Like
What you can do is put a body position at the level you want it to stay at, and then have the max force be Vector3.new(0,1e7,0)
and then set the power to something pretty high (and the Dampening, too, probably around 500-ish). That should maintain it’s y-position.
1 Like
I don’t want it to fully maintain its y position, I do want it to eventually reach the ground, should I just slowly lower the velocity or something else?
You can try that to start, but if that doesn’t work try to test your calculations for velocity on a part in the air so that way there’s nothing that can interfere with it. If that still shoots upwards, then there’s probably a problem with how the velocity is being formulated (though it looks fine)
Another thing, before you enable the velocity that you’ve set for it, set it’s velocity to Vector3.new(0,0,0)
and see if that helps. If the part is anchored while it still has velocity, that velocity will maintain itself until unanchored
2 Likes