How to make player rotate to the slope they are walking on?
Asked by
7 years ago Edited 7 years ago
To explain what I'm trying to do;
A humanoid for example walks up a ramp. The humanoid acts as if hes still walking on flat ground trying to walk through the ramp instead of walking up the ramp.
I want to prevent this.
01 | local mouse = game.Players.LocalPlayer:GetMouse() |
02 | local moveModel = game.Players.LocalPlayer.Character; |
04 | mouse.TargetFilter = moveModel |
08 | local hrp = c:WaitForChild( "HumanoidRootPart" ) |
09 | local j = hrp:WaitForChild( "Root Hip" ) |
12 | function placeAtMouse() |
17 | local point = moveModel.Torso.Position; |
20 | moveModel.Torso.Position, |
21 | Vector 3. new( 0 , - 10 , 0 ) |
23 | local hit, pos, normal = workspace:FindPartOnRay(ray, moveModel) |
25 | local origin = point + Vector 3. new( 0 , 0.1 , 0 ) |
28 | local ray = Ray.new(origin, Vector 3. new( 0 , - 1 , 0 )) |
31 | local cross = Vector 3. new( 0 , 1 , 0 ):Cross(normal) |
32 | local angle = math.asin(cross.magnitude) |
33 | local dude = script:WaitForChild( "AngleValue" ) |
36 | local savedCFrame = moveModel.Torso.Orientation; |
41 | j.C 0 = orig*CFrame.fromAxisAngle(cross.magnitude = = 0 and Vector 3. new( 1 ) or cross.unit, angle) |
56 | game:GetService( "RunService" ).RenderStepped:connect( function () |