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

How do I make the camera always face the back of the player?

Asked by 4 years ago

So I am making a racing game, and the make it more advanced, I want to make it so the camera always faces the back of the player, and the player can't zoom in or out. How do I achieve this?

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

The methods of CFrames sound pretty handy in this case..

assuming you have access to the player's character, here's a method that might hopefully work

01local RunService = game:GetService("RunService");
02 
03local camera  = x.y.Camera--the camera object
04local character = x.y.Character --the player's character
05 
06RunService.Stepped:Connect(function()
07    camera.CameraType = Enum.CameraType.Scriptable
08    local head = character.Head;
09 
10    local behind = head.CFrame:ToWorldSpace(CFrame.new(0, 0, 10));
11    camera.CFrame = CFrame.new(head.Position, behind.Position)
12end)
0
I get "Attempt to index nil with 'x'" YelloMynamesZak 85 — 4y
0
idk the structure of ur script, access the player's camera and character in the context of ur script. this is an example... User#23252 26 — 4y
Ad

Answer this question