Hi guys,
I know Ice is a little Slippery by default, but I want to make it even more so.
I have attempted to mess with the CustomPhysicalProperties already, and have previous posts on the issue; but I cannot seem to get anything going.
I use raycasting in my game to check the FloorMaterial and if the material is Ice, then I go about changing the Physics for it.
Here is my code for reference:
Summary
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local HRP = character.HumanoidRootPart
local RunService = game:GetService("RunService")
local Workspace = game.Workspace
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Blacklist
rayParams.FilterDescendantsInstances = { character }
local Material
local CustomProperties = workspace.Terrain.CustomPhysicalProperties
local DefaultPhysicalProperties = PhysicalProperties.new ( 0.7, 0.3, 0.5, 1, 1 )
local SlipperyPhysicalProperties = PhysicalProperties.new ( 0.7, 0, 0.5, 100, 1 )
RunService.Heartbeat:Connect(function()
local origin = HRP.Position
local direction = HRP.CFrame.UpVector * -5
local result = Workspace:Raycast(origin, direction, rayParams)
if result then
Material = result.Material
if Material == Enum.Material.Ice then
print("we got ice yuh")
if CustomProperties ~= SlipperyPhysicalProperties then
CustomProperties = SlipperyPhysicalProperties
print("we slippin")
end
else
if CustomProperties ~= DefaultPhysicalProperties then
CustomProperties = DefaultPhysicalProperties
end
end
else
return
end
end)
while 1 == 1 do
print(Material)
wait(.5)
end
Now I am not if my code is not right for what I want, so I included that just incase.
However, I know the code is working to some extent because the print functions are working, but the Physics are just not being changed.
![]()
When testing I watch the CustomPhysicsProperty tab under Terrain, and no changes happen at all, even after the print functions work.
If anyone can give me some insight and get me moving in the right direction, then please comment! Any help will be appreciated!
PS. If anyone knows where the default Slipperyness from Ice comes from, please let me know! I would rather make the changes there.