Camera Manipulation

Im still learning lua, and ive gotten to the point where i need to use camera manipulation on my game.

ive used many tutorials and asked people, and i dont really understand how to change the camera offset based on the characters root part position.

ive tried to use

Camera.CFrame == (char.Head.CFrame, number, number)

and run that with RunService.RenderStepped, but it doesnt update the CFrame, and keeps printing the same CFrame value over and over again.

any help or explanations would help a lot :slight_smile: thanks

Alright so basically explain exactly what you want to code

im trying to just code a top down view with a slight angle… similar to the one found in animal crossing games.

This is an extremely in depth article that you should check out to understand the basics of Camera Manipulation:

If you want us to help you with something specific, can you explain your question in more detail? Edit: you did

1 Like

Well first off you cant do anything with the camera unless you set it to scriptable, basically setting a camera to scriptable makes it so you can actually script it, its an Enumeration used for the CameraType property of Camera, after you set to scriptable then you set the CFrame in a local script

OK. So to do this, you will need to constantly set the CFrame Position above the characters head, with a LookVector that is facing the character. Let me whip up a quick example.

Just a note; you’re using the wrong type of operator in your code. The == should only be used to compare two values. You’re using it to change a value; for that you should use the = operator.

This is not tested, but this is the basics of how you could go about this:

player = game.Players.LocalPlayer
character = player.Character
hrp = character:WaitForChild("HumanoidRootPart")

camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable

RunService = game:GetService("RunService")

RunService.RenderStepped:Connect(function() --use RenderStepped to refresh the camera, every time the player's screen is refreshed
    camera.CFrame = CFrame.new(hrp.Position + Vector3.new(0,10,0), hrp.Position) --set the CFrame of the camera to be 10 studs above the character, and looking down at the HumanoidRootPart
end)

If you wanted to add a tilt, you could just shift the first parameter(Position) of CFrame.new to one side a tad.

Oops, replied to the wrong person. My apologies :slight_smile:

1 Like

I accidentally said this to ExcessEnergy, but I will say it to you again to make sure you see it. Make sure you are using the = operator instead of the == operator to change values. You are using the == operator, which is used to compare two values; you should instead use the = operator.

good catch, im aware, just a bad habit lol

1 Like

oooh, the vectors and stuff have been confusing me for some reason, but this code clears it up for the most part, :slight_smile: thanks for the help

1 Like