Help with spaceship's camera controller

Hi! I’m currently trying to figure out how to make a camera system like this one:

It looks like it uses BodyPosition and BodyGyro but that’s not the problem. I’m trying to make that the camera sort of moves with the ship’s orientation and the mouse is still able to control it, like in the video.

I already have a working controller for my spaceship but I’m not able to replicate a camera controller like this one. How would you go about this?

Thanks in advance :slight_smile:

1 Like

You said that you’ve already tried something, so what’s the issue you’re having?

I’m already able to fly the ship but I don’t know how I could make a camera system like in the video above.

I don’t have any issues. I just don’t know how to do it.

You can offset the camera from the ship by a specific translation and rotation like so:

--a bit up and a bunch behind, and pitched a bit down to bring the ship closer to the center of the screen
local cameraOffset =, 5, 20) * CFrame.Angles(-0.1, 0, 0) 

    camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = ship.PrimaryPart.CFrame * cameraOffset

You can lock the mouse to the center of the screen by setting UserInputService.MouseBehavior, like so:

UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter

I’ve had some issues where setting it right as the player joins doesn’t work. The simplest fix is to wait() a bit before setting it or just setting it on every InputChanged :woman_shrugging: :
You can get the amount of mouse movement that the player “tries” to create, and react to it, like so:

	InputS.MouseBehavior = Enum.MouseBehavior.LockCenter

	if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
		local character = player.Character
		if character then
			character.HumanoidRootPart.CFrame = character.HumanoidRootPart.CFrame * CFrame.Angles(0, inputObject.Delta.X*-0.01, 0)

I think this is enough to get started. To get something more like in the video you posted, you can smooth the movement over time or have it set a “target” CFrame that some BodyMovers or Constraints then make it move/rotate towards, to get a more “physics” like feel.

Let me know if you have any questions or need help with getting it to be more like what you had in mind :slight_smile: