So I'm working on something similar to the Frost Walker boots from Minecraft, for my game Sorcery, but I came across this problem.
I have no way of telling if the player is walking on water, or on ice.
If I ever wanted to check if the player was touching water before, I just checked if what it hit was the terrain object, but now I have no way to distinguish between Ice or Water.
Right now, the player just goes flying up, creating hilariously interesting towers.
However, this is not my intended behaviour.
Is there any easy way of checking the material of a specific part of the terrain?
And just in case you were wondering, if you check the material property of the terrain, no matter where you hit it from, it just returns Plastic.
(Roblox is made of plastic confirmed?)
Code:
char = script.Parent repeat wait() until char.Head print'START' while wait() do local ray = Ray.new( char.Head.CFrame.p, -- origin ((char.Head.CFrame.p - Vector3.new(0,1,0)) - char.Head.CFrame.p).unit * 500 -- direction ) local ignore = char local hit, position, normal = workspace:FindPartOnRay(ray, ignore) if hit == workspace.Terrain then workspace.Terrain:FillBall(position,3,Enum.Material.Ice) spawn(function() wait(2) workspace.Terrain:FillBall(position,3,Enum.Material.Water) end) end end
Additional links:
http://wiki.roblox.com/index.php?title=API:Class/Terrain https://www.roblox.com/games/1293192884/Sorcery-Alpha
It looks like you'll have to use the terrain's ReadVoxels method. This returns two arrays, although I'm not quite sure in what format, but the first contains the terrain material.