As you can see it works perfectly fine on surfaces that are less then 180 degrees
but as soon as I past it,
it stops working
here’s the code
rotationX = ((rayFront.Position.Y-rayBack.Position.Y)*3)
rotationX = CFrame.Angles(math.rad(rotationX),0,0):ToWorldSpace()
vehicle.Body.BodyGyro.CFrame = CFrame.Angles(0, math.rad(rotationY), math.rad(rotationZ)) * rotationX
1 Like
this wont be helpful but when i used cframe angles when it past 180 degrees it started to glitch aswell it was a turning head but i dont think this will be that helpful for you, you tried math.rad aswell
hasanchik
(hasanchik)
January 7, 2024, 5:40pm
#3
I think you might need to use the RayResult.normal, which is basically the direction a surface is pointing at.
vehicle.Body.BodyGyro.CFrame = CFrame.new(rayBack.normal) --Or CFrame.angles
^^ not tested
Hi! Quick question, how can I match a part’s orientation to a ray’s normal?
I tried checking the DevForum and Wiki, and if I understood correctly, a Raycast Normal vector is basically the perpendicular vector of the ray.
What I’m trying to do is basically spawn parts whose orientation match the terrain’s slope. Example:
[image]
I managed to make the parts spawns on the appropriate Y level, but unfortunately I can’t seem to match their orientation to the slope, as you can see in this screens…
1 Like
didn’t work. i have no idea why its not working past 90deg
Still wont work, i still donw understand why??? any ideas guys???