Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

preventing custom camera from being able to look through walls?

Asked by
Astralyst 389 Moderation Voter
6 years ago
Edited 6 years ago

I've been making a custom camera, and I need the camera to not be able to look through walls,

(the best way to explain "looking through walls" is, try have shiftlock on and stand against a wall on your right side, the camera will clip through it)

This is the closest that I've got.

01local Raycast = Ray.new(Head.Position, (Camera.CoordinateFrame.p - Head.Position).unit * Offset.Value)
02    local Part, Pos = workspace:FindPartOnRayWithIgnoreList(Raycast, Character, false, true)
03    if not Part then
04      Camera.CoordinateFrame = CFrame.new(Head.Position)
05        * CFrame.Angles(0,math.rad(AngleY),0)
06        * CFrame.Angles(math.rad(AngleX),0,0)
07        * CFrame.new(1,.5,Offset.Value)
08    else
09      Camera.CoordinateFrame = CFrame.new(Head.Position,Pos)
10        * CFrame.Angles(0,math.rad(AngleY),0)
11        * CFrame.Angles(math.rad(AngleX),0,0)
12        * CFrame.new(1,.5,Offset.Value)
13    end

It pretty much works; however, the camera would just spas like crazy when I try to look through a wall, how would I fix/or is there a better way of doing stuff?

0
u nvr give full script and im too lazy to redefine everything lol TheluaBanana 946 — 6y
0
nevermind, solved it Astralyst 389 — 6y

1 answer

Log in to vote
0
Answered by
Astralyst 389 Moderation Voter
6 years ago

nevermind, solved it by lerping.

Ad

Answer this question