-
What do you want to achieve? Keep it simple and clear!
I want to make my placement system work on terrain but it only works on parts. My placement system is a rust building system and it snaps to attachments. -
What is the issue? Include screenshots / videos if possible!
It only works on parts. Here’s my script:
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried YT and Devforum
I think that is cause the Terrain doesnt is a Raycast.Instance, so on your code if u only check if the raycast hits something it will ignores the terrain.
Hope that this helped!
-- wrog way
if Raycast and Raycast.Instance then
-- ...
end
-- right way
if Raycast then
-- ...
end
thanks for responding, I tried this but it still doesn’t work
can you record a video, with whats is happening?
u can use Mouse.Hit instead of using raycasting
I have the whole thing done for ray casting though, I don’t wanna change and also i need raycasting for my attachment script
i’ll try to recreate it on my studio to help you, just wait a little bit and i’ll send you the solve of the problem!
oh ok, thanks I appreciate it.
This is false, RaycastResult
will provide the Terrain object as its Instance
field if that’s what it hit.
What he wrote isn’t wrong, it’s just redundant since Instance
is guaranteed to not be nil if the returned RaycastResult
isn’t nil.
@RetroAmythest You probably need to extend the length of your unit ray and change its origin since it’s only doing casting 1 stud. Terrain raycasting acts on a hollow shell rather than a solid volume, so it might miss the raycast if the origin of the ray is too close to the terrain surface. I’m guessing that you’re using deprecated Mouse
object. It’s useful but not recommended.
Does the origin of your raycast come from Camera:ViewportPointToRay
? If not, I would recommend using that. Check out the documentation they provide on the page. You can use it in combination with UserInputService:GetMouseLocation
i was searching here in raycast, you can use Ray.new() and workspace:FindPartOnRayWithIgnoreList()
what u can do:
function Raycast(origin, direction, ignoreList, terrainCellsIsCubes, ignoreWater)
local part, pos, normal, material = workspace:FindPartOnRayWithIgnoreList(Ray.new(origin, direction, ignoreList, terrainCellsIsCubes, ignoreWater))
return {
Distance = (origin - pos);
Instance = part;
Material = material;
Normal = normal;
Position = pos;
}
end
sorry for the late answer!
Thanks, i’ll try this and let u know if it worked
Hey, i changed to mouse and it still doesn’t work on terrain for some reason
Guys, it just turns out I had some code in the wrong place
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.