Camera Replication Focus - A package for StreamingEnabled games that use a scriptable camera

The Problem

If you’ve worked with StreamingEnabled, one thing you may have noticed is that your cutscenes or custom freecam won’t load nearby terrain and instances because of ReplicationFocus. By default, it’s set to the player’s character and that’s problematic because your camera isn’t always near the character when you run a cutscene or go into your custom freecam.

You can tell others have ran into this problem in the past:

The Solution

So, what is the solution to this problem? Well, the solution that I came up with is one where the server creates a part for a player and its client handles moving the part to the player’s camera. Don’t worry if you’re confused, you can find a step-by-step breakdown of this solution below.

How It Works

→ The client asks the server to create a part that will be used as the ReplicationFocus

→ The server creates the part, gives it a tag that the client listens to, sets its name to the player’s UserId, anchors it, and moves it to their character or their current camera CFrame

→ When the part streams in, the client will starting moving the part to the current camera CFrame and then ask the server to unanchor the part and give it network ownership

→ The server receives the request and unanchors the part and gives the player network ownership

→ The client asks the server to cleanup the part when it’s done with it

→ The server destroys the part and sets the ReplicationFocus back to the character

With this solution, even though you’re constantly setting the part’s CFrame, you’re not constantly firing a RemoteEvent for updating the part. Remember, the network ownership belongs to the client and that’s what allows the changes on the client to replicate to the server and other clients.

Available for Free

This resource can be as used either a starting point to solving your problem or maybe even the solution to your problem! The provided package has the client ask for a ReplicationFocus part only when the player’s camera has its CameraType set to Enum.CameraType.Scriptable!

If you’re worried about the player’s character falling to their death when the ReplicationFocus is far from its character, you shouldn’t need to. I’ve considered this and it looks like the player’s character freezes in the air when this happens, so they shouldn’t fall to their death.

Known Issues

  • The provided package does not account for when a player moves the ReplicationFocus part below the destroy height. This means that it is rare, but possible for the part to be destroyed due to this. If that happens, the code should not break, but the ReplicationFocus will get set back to the character.
  • The provided package doesn’t work with the built-in freecam because it keeps the CameraType at Enum.CameraType.Custom. You will more than most likely need to make your own freecam or fork the built-in freecam.
  • Hopping over to the server view while in Play Solo will cause the part to fall below the destroy height because the client is no longer sending information to the server. This is presumeably a quirk of using Play Solo.

Setup

  1. Download the .rbxm file attached below or take the free model linked below
  2. Insert the model into ReplicatedStorage

Download Now Available on Roblox
14 Likes

Clever workaround! I like that you used Network Ownership instead of replicating manually, saves really a lot of bandwidth

1 Like

I’d like to think so, but something tells me that using a remote event has the potential to be better. Maybe not right now, but maybe when unreliable events become a thing. They’re on the roadmap for Late 2023 at the moment.

This is exactly what I needed! Thank you for sharing that!