Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local man = workspace.man22
- local root = man.HumanoidRootPart
- local viewp = Instance.new("Part",man)
- viewp.Material = "Neon"
- for i = 1,30*15 do
- local normal,hitp do
- local ray = Ray.new(root.Position,root.CFrame.upVector * -40)
- local _,hitpos,norm = workspace:FindPartOnRay(ray,man)
- normal = norm
- hitp = hitpos
- end
- -- the character's upvector will be the normal
- -- the character's lookvector will stay the same
- -- the character's rightvector will be upvector:cross(normal)
- local upvec = normal
- local lookvec = root.CFrame.lookVector
- local rightvec = normal:Cross(lookvec)
- -- construct a new cframe from the right, up, & lookvectors
- local trgcf = CFrame.fromMatrix(root.Position, rightvec,upvec,lookvec)
- viewp.CFrame = (trgcf-trgcf.p) + hitp + normal*.5
- -- convert it to object space, so it can be used in C1
- local nu_cf = root.CFrame:ToObjectSpace(trgcf)
- -- C0 needs to be reset first!!!
- root.RootJoint.C0 = CFrame.new()
- -- now, set C1 & see what happens
- root.RootJoint.C1 = nu_cf
- wait()
- end
- viewp:Destroy()
- print("ended")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement