sigh, 3rd time’s the charm.
Here’s where I’ll post my creations regarding any Arcane Universe-related development.
Unsure if this’ll become an actual game.
sigh, 3rd time’s the charm.
Here’s where I’ll post my creations regarding any Arcane Universe-related development.
Unsure if this’ll become an actual game.
Dynamic camera field of view based on how much the player looks up using a dot product and the absolute Y velocity of their character.
The Yaw and Pitch are calculated on the sender’s client rather than on the receiver’s, just so the receiver doesn’t have to calculate everyone’s yaw and pitch in a 20 player server.
uses a total of 8 bytes on top of roblox’s base networking overhead, in total sending 22 bytes per second over the network at 15fps.
It uses buffers to compress the Yaw and Pitch into S8[1], as it has enough precision.
S8 is only 1 byte, but as I need to send the player’s userid to every client, it uses a S32[2] as compression, which is unfortunately 4 bytes.
It’s dead simple, I just smooth the yaw and pitch on the receiver’s side… and that’s it.
Very, I haven’t yet added level of detail[3], nor have I added a change gate[4].
I still haven’t tested with more than 1 other player, but I can possibly change it to only 10FPS whilst increasing the smoothing minimally.
We can calculate how much a single player is sending to the server per second; 22 bytes x 15 = 220 bytes per second.
Which means, at 50 players[5], the server will receive 50 x 220 bytes/seconds = 11,000 bytes per second.
Which then finally means that the server sends the data to the other 49 players, and hence will cost; 50 x 49 x 22 x 10 = 539,000 bytes per second, or better called 0.539 megabytes per second.
I should likely not use 50 players, so I’m going to try to calculate at only 20 players; 20 x 19 x 22 x 15 = 125,400 bytes per second or 0.1254 megabytes per second, significantly better.*
If you wish to mess around with this calculation, I have created a Desmos File with explained variables.
Dear god…
![]()
There’s more.
No…
I feel like a significant other of a cosmos horror movie protagonist watching them slowly descend into madness as they comprehend the incomprehensible
![]()
I don’t understand eldritch script, darling, please use english
Bucket’s off-spring.
Implemented a camera shaker module to prevent using legacy techniques[1], for now I’ve only used it for creating a small shake when landing, it’ll only trigger after a second in the air.
I should change it to rather just reduce the intensity so high falls create a large shake but lower falls create slight but still noticeable shakes.
Fat.
e.g. Humanoid.CameraOffset ↩︎
Made the experience where I’ve done these shenanigans public.
Should the character look at the camera when you’re facing towards the front of your character, or do as it do right now by trying its best to look backwards?
Personally I’m fine with how it is at the moment but maybe wait for a few other people’s opinions
I’d love code samples as well if you’re willing to give them
Sure, of course I won’t give everything, but what specifically interests you?
just the
thing (the code that makes the player character look where the camera looks)
Ooh, yeah I can send that.
It’s rather simple code for convincing the player everything tall is taller than its supposed to be, as well as making falling seem a bit faster.
It’s not fully fleshed out due to the fact I am planning to make FieldOfView a result of a a valuemanager, so I will have one module controlling the FoV, and hence I can add offsets and multipliers as I want.
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer or Players.PlayerAdded:Wait()
local Modules = ReplicatedStorage.Modules
local Packages = Modules.Packages
local Camera = workspace.Camera
local Bucket = require(Packages.Bucket)
local BASE_FOV: number = Camera.FieldOfView
local MAX_VELOCITY: number = 80.0
local VELOCITY_ZOOM_MULTIPLIER: number = 5
local DOT_ZOOM_MULTIPLIER: number = 10
local SMOOTHING: number = 4.0
local Connections: Bucket.Identity = Bucket()
local CurrentOffset: number = 0
local function CharacterAdded(Character: Model)
local Humanoid = Character:WaitForChild(`Humanoid`):: Humanoid
Connections:Add(RunService.PreRender:Connect(function(DeltaTime: number)
if not Humanoid.RootPart then
return
end
local DotToUpwards: number = Camera:GetPivot().LookVector:Dot(Vector3.yAxis)
local DotOffset: number = math.pow(math.max(0, DotToUpwards), 2) -- To make it non-linear, e.g. when the player only looks up a bit, it won't seem as much as if they look up more.
local TargetOffset: number = math.clamp(math.abs(Humanoid.RootPart.AssemblyLinearVelocity.Y) / MAX_VELOCITY, 0.0, 1.0) * VELOCITY_ZOOM_MULTIPLIER
CurrentOffset += (TargetOffset - CurrentOffset) * math.min(SMOOTHING * DeltaTime, 1)
Camera.FieldOfView = BASE_FOV + CurrentOffset + DotOffset * DOT_ZOOM_MULTIPLIER
end))
Character.AncestryChanged:Once(function()
Connections:Destroy()
end)
end
local function Start()
if Player.Character then
CharacterAdded(Player.Character)
end
Player.CharacterAdded:Connect(CharacterAdded)
end
return {
Start = Start
}
2 things: