You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
Imagine the part on top is the humanoid root part, and the part on the bottom is the particle that is being raycasted onto the surface. What I want is for the bottom part to have the same y-axis orientation as the humanoid root part whilst still tilting on the surface it was raycast on.
- What is the issue? Include screenshots / videos if possible!
The problem is I have no idea where to even start when using CFrames for this problem. So far I raycast down, and set the particle parts cframe to the a cframe of the position + the raycast normal. I also believe it would involve using either the :ToWorldSpace or :ToObjectSpace events.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have looked on dev forums, but have yet to see any specifically dealing with raycasting normals and toworldspace or toobjectspace. This is the current line of code I have, and it almost works, but sloped surfaces change the orientation of the particle part. Here is a video of the problem, I want it coming out of the back of the player like it is on the flat surface and the sloped surface to the left, but for some reason on the other sloped surface it comes out towards the side.
Here is the code I have implemented currently to get the CFrame that the particle part gets.
----- get the part orientated to the surface, facing straight up. local newCFrame = CFrame.new(slideResult.Position, slideResult.Position + slideResult.Normal) ----- cframe to use in the final cframe :ToWorldSpace event local angleCFrame = CFrame.Angles(0,0,math.rad(-character.HumanoidRootPart.Orientation.Y)) ----- the final cframe. The angles cframe at the end is to rotate the particle by 90 degrees and get it facing the right way. local finalCFrame = newCFrame:ToWorldSpace(angleCFrame) * CFrame.Angles(0,math.rad(90),0)
Any help would be appreciated as I absolutely suck when it comes to CFrames.