Hello, I would like to know how to use velocity in two axes at the same time (X and Y axis), the idea of this is that when a ball collides with the box the ball is thrown with the velocity in the X and Y axis.
How could I do that?
Hello, I would like to know how to use velocity in two axes at the same time (X and Y axis), the idea of this is that when a ball collides with the box the ball is thrown with the velocity in the X and Y axis.
How could I do that?
You can use body movers.
local debris = game:GetService("Debris")
box.Touched:Connect(function(partTouched)
if partTouched == ball then
local bodyVelocity = Instance.new("BodyVelocity",ball) --create a body velocity and parent it to the ball
bodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge) -- Determines the limit on how much force that may be applied to each axis
bodyVelocity.P = 1000 -- Determines how aggressive of a force is applied in reaching the goal velocity
bodyVelocity.Velocity = ball.CFrame.lookVector * 100 + Vector3.new(0,50,0) -- make the goal of the velocity 100 studs out from where the ball is looking and up 50 studs.
debris:AddItem(bodyVelocity, 0.5) -- deletes the bodyVelocity after 0.5 seconds. You can adjust this value and the other values above to your liking
end
end
If you have any issues let me know.
This discussion is preserved as it was. New answers, comments, and votes are closed.