Khaelis' Arcane Shenanigans

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.


3 Likes

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.


High jumping, not tuned whatsoever to mimic WoM or AO.
The animation is done via a separate module to prevent modification of the high jump logic code, which means in case I want to add sounds, I can just add another module.

Character looking with 15FPS replication, the NPC is entirely client-sided as it just searches for the closest player.

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.

But how does it achieve 22 bytes?

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.

But how do you get it to be smooth at 15FPS?

It’s dead simple, I just smooth the yaw and pitch on the receiver’s side… and that’s it.

Is it possible to optimize this further?

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.

How much bytes per second is it sending across the network at X players?

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.


  1. Signed 8-bit ↩︎

  2. Signed 32-bit ↩︎

  3. Further distance = lower update rate ↩︎

  4. only send if the angles have changed by a small value, preventing idle players from using up network. ↩︎

  5. I’ve chosen 50 for X. ↩︎

3 Likes

EVILLL code.

Dear god…
image

2 Likes

There’s more.

2 Likes

No…

1 Like

I feel like a significant other of a cosmos horror movie protagonist watching them slowly descend into madness as they comprehend the incomprehensible

1 Like

image

1 Like

I don’t understand eldritch script, darling, please use english

1 Like

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.


  1. e.g. Humanoid.CameraOffset ↩︎

1 Like

Made the experience where I’ve done these shenanigans public.


Scandin Space Program

2 Likes

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

1 Like

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.

Code
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:

  1. Can I put this in my game(s, including potential future ones) (with credit ofc)
  2. Thanks! :grinning_face:
1 Like