The white block is the place where ray hit, but as you can see, the blocks of the wall slam effect are planks even on the side of grass, so I want to make blocks get the material and color of the place where they are located, I guess raycasting is a solution here:
local ray = workspace:Raycast(Rock.CFrame.p,???,rayParameters)
I’ve tried to write (Rock.CFrame * CFrame.new(0,0,-5)).p, but it didn’t work sadly.
The orientation of rocks is random, so I think CFrame.lookVector doesn’t work here, so I need an alternative.
Can you help me find out what should I write instead of “???”, so the rocks will get their material, also make it so it will work on any direction the ray hit? ( I mean it will work no matter what direction the origin of the first ray was facing: Left, Right, Forward, Back)
Could you not cast a ray at the reverse normal of the original ray on each of the parts as to figure out what material theyd be? It’d look something like such:
-- Whatever loop you have, creating the part, etc
local partRay = workspace:Raycast(part.Position, -originalRay.Normal * 5)
if partRay then
part.Material = partRay.Instance.Material
part.Color = partRay.Instance.Color
end
Thank you for the response, for some reason, this doesn’t work, none of the rocks got it’s material.
You can check all the code in the previous topic to test it by yourself, but I think that all we need is guess the right vector from the block. Maybe Vector3.fromAxis() can help here?
Your best shot is to cast rays from the crater parts before changing color and material, facing the same direction as the slam occurs(the normal). After the raycast, change the color and material to the corresponding part hit by the ray.
Alright, I’ll try to do it your way, but I’ve found that if I use Vector3.FromNormalId(Enum.NormalId.Front)*-5, it will work partially, so maybe we can test some of Vector3 constructors?