#Steam Workshop::Roblox style camera

1 messages · Page 1 of 1 (latest)

elfin briar
#

@astral basin have you tried this not in single player?

elfin briar
#

It produces weird results

astral basin
#

like what?

astral basin
elfin briar
#

Not at home

astral basin
#

oh ok

astral basin
astral basin
#

that is weird

#

this is the code that controls that

#

would it be because of those angle_p/y convars?

elfin briar
astral basin
#

its annopying because SetupMove is the only shared relm hook

#

and CalcView only sets the variable on the client

#

yeah no it doesnt work

astral basin
# elfin briar

i think i figured out what was happening, i tried to make a fix but idk if it works. could you test it for me?

astral basin
#

thanks

elfin briar
#

I don't know why but when the addons in the server content pack it doesn't start but when I extract the lua files and put them in an addon they start

#

it's still not working on a server

#

and you left a print in

astral basin
#

oh huh

astral basin
#

the only solution then is to have it only run on the server

#

maybe

#

ill try that

astral basin
elfin briar
astral basin
#

thats super annoying

astral basin
elfin briar
#

same thing

astral basin
elfin briar
elfin briar
#

oh

astral basin
#

maybe this?

elfin briar
#

that's the function that should be called on both

astral basin
elfin briar
astral basin
#

right ok

#

is there any other way i could get the cameras angles maybe?

elfin briar
#

FinishMove?

astral basin
#

same context

elfin briar
#

Finish move makes me spin the direction I'm holding

astral basin
#

that just means SetMoveAngles isnt being set

elfin briar
#

I'm not sure

astral basin
#

im fairly sure its all because this isnt being set on the client for some reason

#

im not sure why

elfin briar
#

are the convars allowed to be called on server like that

astral basin
elfin briar
#

I don't think you can use convars like that on the server

#

per person

#

Maybe NWInt and NWBool?

astral basin
#

i didnt even know that was a thing

#

ill try that

astral basin
elfin briar
#

yes

astral basin
#

ok

#

gime aminute

elfin briar
#

yes

#

clients only need their own data

#

run in shared

#

then the server has the data

astral basin
# astral basin

but this implies that if i set it on the client the server wont see any change

elfin briar
#

okay

astral basin
#

i mean it works fine for most of the other hooks, but a big reason for using convars was that it seemed to be shared between the server and the client

elfin briar
#

no

#

it's shared in singleplayer

astral basin
#

really?

elfin briar
#

that's the problem we're having

#

I think

astral basin
#

thatd make sense

astral basin
elfin briar
#

I don't know

#

I'm trying

local camAim
if CLIENT then camAim = Angle(GetConVar("roblox_cam_angle_p"):GetFloat(), GetConVar("roblox_cam_angle_y"):GetFloat(), 0) end
if SERVER then camAim = Angle(ply:GetNWInt("roblox_cam_angle_p"), ply:GetNWInt("roblox_cam_angle_y"), 0) end
print(camAim)```
#

it works

#

but it's laggy

#

if CLIENT then
    local cacheP = 0
    local cacheY = 0
    hook.Add("InputMouseApply", "rbxCamCalc", function(cmd, x, y, angle)
        local ply = LocalPlayer()
        if not ply.rbxFreeCam then ply.rbxFreeCam = angle end
        ply.rbxFreeCam.p = math.NormalizeAngle(ply.rbxFreeCam.p + y / 50)
        ply.rbxFreeCam.y = math.NormalizeAngle(ply.rbxFreeCam.y - x / 50)
        ply.rbxFreeCam.p = math.Clamp(ply.rbxFreeCam.p, -89, 89)
        getAng(ply.rbxFreeCam)
        if cacheP ~= ply.rbxFreeCam.p or cacheY ~= ply.rbxFreeCam.y then
            cacheP = ply.rbxFreeCam.p
            cacheY = ply.rbxFreeCam.y
            net.Start("roblox_cam_angle")
            net.WriteEntity(ply)
            net.WriteInt(ply.rbxFreeCam.p, 32)
            net.WriteInt(ply.rbxFreeCam.y, 32)
            net.SendToServer()
        end
        if distChanged and GetConVar("roblox_cam_classic"):GetBool() then ply.rbxFreeCam.p = camSkew.p end
        if GetConVar("roblox_cam_shiftlock"):GetBool() and not ply:InVehicle() or GetConVar("roblox_cam_dist"):GetInt() < 1 then return end
        return true
    end)
end

if SERVER then
    util.AddNetworkString("roblox_cam_angle")
    net.Receive("roblox_cam_angle", function(len)
        local ply = net.ReadEntity()
        local p = net.ReadInt(32)
        local y = net.ReadInt(32)
        ply:SetNWInt("roblox_cam_angle_p", p)
        ply:SetNWInt("roblox_cam_angle_y", y)
        print("recieved")
    end)
end```
#

just need a better way to send data to the server in InputMouseApply

astral basin
#

works fine in single player

astral basin
#

tried it and it seems to do the same thing

#

idk how itl react on multiplayer

#

might be exactly the same

elfin briar
#

The lag is a net issue

#

not reading NWInt

astral basin
#

oh ok

astral basin
# elfin briar

that kinda almost looks like its trying to aim towards where you were last standing

#

thats realy weird

elfin briar
#

I don't know how to network it better

astral basin
#

idk if you can

astral basin
elfin briar
#

are you using this?

astral basin
#

yeah

elfin briar
#

sure

astral basin
#

idk what else i could do

elfin briar
#

not have it work in multiplayer

#

for some reason the addon doesn't work in a content pack on the server

astral basin
#

like as the .gma file?

elfin briar
#

as in +host_workshop_collection

astral basin
#

idk, im not familiar with gmod servers

astral basin
elfin briar
#

no

astral basin
#

oh ok