Please, anyone knows how to detect terrain material with RayCasting?
Is this a bug??
I used the normal way of Raycasting
, it works perfectly as it should. Here’s how:
-- This script is in StarterCharacterScripts
local character = script.Parent; -- Getting the character which is the parent of the script
local runService = game:GetService("RunService") -- Getting RunService
runService.RenderStepped:Connect(function()
local ray = Ray.new(character:WaitForChild("HumanoidRootPart").Position, Vector3.new(0, -50, 0)) -- Casting a ray
local part, pos, _, material = workspace:FindPartOnRayWithIgnoreList(ray, {character, workspace.Baseplate}) -- Ignoring baseplate and character
if part then -- Checking if the part exists
print(part.Name) -- Prints (Terrain)
if material then -- Checking if the material exists
warn(material) -- Prints (Enum.Material.Grass)
end
end
end)
Didn’t new it returned a 4 parametter returning terrain, thanks! <3
wait… what about new WorldRoot:RayCast()
That’s what I need to know
It returns the same or no?
Because, RayResult.Material on terrain returns Enum.Material.Plastic
I tried using workspace:Raycast()
, but it returned everything same as you. The material was even Plastic, but it’s fine on Ray.new()
.
Weird, My trust level ain’t enough yet… could you report on engine bugs?
My trust level also isn’t enough yet, also can you please mark that as a solution if that helped?
Use RaycastResult.Material
instead of RaycastResult.Instance.Material
.
I used that, it just printed plastic.
No, you did not. thirtycharacters
See the post again. I’m not the one who created it.
That’s what I’m doing, still, doesn’t works and prints Enum.Material.Plastic
Why the offensive tone? You’re just making me not want to help. I completely misread the reply.
I simply printed this in studio to confirm what’s causing it.
This is exactly what you’re doing with RaycastResult.Instance.Material
.
Maybe, try deleting the baseplate. I think it‘s because of the baseplate that is at the same level as the terrain. So, if you delete the baseplate (that it‘s material is plastic), then you would get the true material.
Roblox Terrain use a 4x4x4 Grid voxel system, wich isn‘t 100% accurate
ok so, how can I fix this? to get material of hitted zone
I just realized @XXgamerisaliveXx is not the OP, my bad.
Simply, like I said…
Thanks!
Though… it’ll be good if Roblox added the Ray.Instance.Material returning terrain material