I’m creating a dodge roll mechanic in my game, and one of the things I’m having trouble with is dealing with certain physics interactions. My dodge roll is set up like this:
Player’s AutoRotate is turned off and their character is rotated in the direction they’ll be launched. They also lose control of their character.
The MaxForce and Velocity properties of the BodyVelocity object inside of the player’s HRP are set (max MaxForce, and a BodyVelocity with a magnitude of ~50 studs/s). The direction of the Velocity vector is the same as the HRP’s lookVector. Power stays at the default 1250.
After .2s, the MaxForce is set to the zero vector, AutoRotate is turned back on, and the player regains control
Here’s a video of the issue (the standard Roblox flinging we’re all familiar with): robloxapp-20211230-0321577.wmv (310.1 KB)
This has worked surprisingly well in creating a roll that feels good to use. However, I’m not entirely sure how I should prevent flinging. It’s especially bad when the player’s character collides with other humanoids. Would really appreciate a solution because I’m not entirely sure how to approach this. The desired behavior would simply be, in the case of the video, the player colliding with the dummy and being stopped by it. Thanks.
Here is the script I use to prevent the player from getting flung after rolling
local connection
connection = char.Hitbox.Touched:Connect(function(part) -- make hitbox whatever part for collisions
if part ~= workspace:FindFirstChild("Baseplate") then
if humrp.Position.Y < part.Position.Y + part.Size.Y/2 then
V:Destroy() --destroy velocity
end
end
end)
Make sure to use Connection:Disconnect after you are done using the script