Side Camera Implementation

Hello. I’m working on a track game and I am wanting to implement a Side Camera so you can also look at other racers to see how close/far they are from you. But I don’t really see I could do it. I want to reference a game called “Speed Stars” For this Idea.

Idk if you can tell but the camera is like rotating along with the track

How can I achieve something like this?

You could set the CameraType to Scriptable and constantly update the cameras CFrame with:
CFrame.new(pos: Vector3, lookAt: Vector3)
Where pos is the position of the players head, but 10 studs to the right. (Use CFrame.RightVector of the players head and multiply it by 10)
And where lookAt is just the position of the players head.

(Edit: This assumes you know how to script to make the player only run on the track)

I haven’t got to that yet but I THINK I know how to make them move in 1 lane and 1 lane only if IM NOT WRONG. You use MoveTo: ? :smile:

I am not too familiar with MoveTo() but from what i could read, it seems like the perfect solution. Btw, i tried to test my idea of updating the camera relative to the characters head, and realized i didn’t think about the head wobble when running. This means the camera swings around, which i assume is not ideal… :sweat_smile: I will update you again if i find a better solution :+1:

Couldn’t I just base it off the X or the Z axis and not the Y?

Yes, that’s possible, but it would still wobble a little bit on the XZ plane. However, i luckily just found out that you could just switch out head with the HumanoidRootPart and it automatically is stabilizes all axes:

local player = game.Players.LocalPlayer
local camera = workspace:WaitForChild("Camera")

camera.CameraType = Enum.CameraType.Scriptable

while task.wait() do
	local character = player.Character
	if character then
		local rootPart = character:FindFirstChild("HumanoidRootPart")
		if rootPart then
			local cameraDistanceToPlayer = 10
			local rightVector = rootPart.CFrame.RightVector * cameraDistanceToPlayer
			local upVector = Vector3.yAxis * 3
			local newPosition = rootPart.Position + rightVector + upVector
			camera.CFrame = CFrame.new(newPosition, rootPart.Position)
		end
	end 
end

If you copy paste that into a localscript in StarterPlayerScripts, you can test it out.

Note: Here you can also adjust the height of the camera by adjusting 3 in:
local upVector = Vector3.yAxis * 3

1 Like

Yeah it works as intended. Thank you.

1 Like

Too do like the auto move though. Would I just like loop MoveTo: or how would I do it?

Yes i think you could have a bunch of invisible ball parts along the edges of the track, whereas the player keeps moving toward the next balls position. How you would determine which ball is next, might also be a challenge. Perhaps you could have all the balls named after numbers and keep updating a variable with the players latest touched ball. And with that you could just get the next ball by incrementing the number of the latest touched ball. (idk if that makes sense :skull:)

1 Like

Is there I can keep in touch with you while I do this. I’ll try this Idea and lyk how it goes.

Yes i will most likely check the dev forums at least once per day :+1:

1 Like

Do you have discord or something like that {char2.0}

Ah I’m sorry, i don’t want to talk, but you can message me if you want. I see you have a discord set with RoPro, I’ll just send a message and you’ll know it’s me.

1 Like

Wait uh it says the username is not correct. If so i can just add you as a friend on roblox and i’ll send you mine

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.