How to get client's camera from server?

I am trying to get the client’s camera properties like CFrame and Focus, and
I want to know what ways are there to get the client’s cameras properties.
I am currently using remotes to poll for the client’s camera which I don’t find efficient.

Thanks in advance,
MXKhronos

2 Likes

There is no other way to get this information other than by polling the client.

Why are you concerned about efficiency? Is it causing you issues in game?

1 Like

Because constantly polling even if the camera had not moved would be a waste of computational resources. In situations like a server with 50 clients, I’m worried if it will hurt performance.

Maybe I could instead FireServer() from client when there’re camera movement.

2 Likes

Oh! I was under the assumption that was the case already, I misunderstood.

I would definitely only send this information when the camera is moved. On top of that if you’re really concerned about how this will scale with player count, I would enforce a minimum time between each update by some small value (ie, 1 request every 0.5 seconds). If the camera changes during the waiting period, save the value and send it as soon as it can.

3 Likes

Why do you need this information on the server? There may exist a better way of doing whatever it is you’re trying to do.

1 Like

Just rendering chunks for clients while CharacterAutoLoads is off, for a FreeCam mode.

2 Likes

Just rendering chunks for clients

Isn’t that alone pretty inefficient? If you’re concerned about performance, this camera thing probably isn’t the problem.

Also, why do you need to do that on the server? Shouldn’t the majority of this be handled by the client?

2 Likes

Most of the assets are stored in server storage to reduce live parts count and load in times.

Some parts are also procedurally generated on server side so I need to know if the player’s camera or Root Part is near those chunks to regenerate, otherwise the instances gets destroyed.

Are you procedurally generating parts to help performance? If so, I strongly recommend not doing that. Stick with StreamingEnabled or no chunks at all. It’s worse than just dealing with a larger map in the long run.

I’ve sent client camera CFrames to the server for debugging and spectating purposes. For example: Player A says he’s found a map glitch, I can click a button on my admin panel and see what this player is looking at without having run to them, or teleport, and then try to guess which direction they’re looking.

1 Like

Of course there are situations where the server does need access to this information, I was not suggesting otherwise. Sometimes though there are better ways to achieve a goal by thinking more generally about the overall problem than a specific area. That’s what we have user stories for.