• Changing player view to third person! HELP :c
    10 replies, posted
Hey there! Well I'm having problems with my prop hunt server... I'm not an expert at LUA, but I can get away with it, normally.. but angles? not my best, ever.. .-. so I installed the "new" prop hunt version... PropHunters by Mechanical Mind.. In this new version you can lock prop rotation, etc.. etc.. but there's some things I don't like in it, that I prefer how they were in the "regular prop hunt" and the most important one is the player view... In this version, for example, if you transform in a cup, your player view is like always matching the prop, so if we are a cup, our player view is near the ground.. and it sucks.. i want to have a 3rd person view!! but i can't figure out where and what to change in the configs, since it's very different from the previous prop hunt configs.. This is how it looks like... Im a cup.. [IMG]http://s12.postimg.org/cla6pydil/measacup.jpg[/IMG] And this is how I would like to look like.. xD (im the bottle of course xD) [IMG]http://s29.postimg.org/u4c12k2tz/howiwant.jpg[/IMG] This was the only view config on the old prop hunt.. [QUOTE][CODE]function GM:CalcView(pl, origin, angles, fov) local view = {} if blind then view.origin = Vector(20000, 0, 0) view.angles = Angle(0, 0, 0) view.fov = fov return view end view.origin = origin view.angles = angles view.fov = fov // Give the active weapon a go at changing the viewmodel position if pl:Team() == TEAM_PROPS && pl:Alive() then view.origin = origin + Vector(0, 0, hullz - 60) + (angles:Forward() * -80) else local wep = pl:GetActiveWeapon() if wep && wep != NULL then local func = wep.GetViewModelPosition if func then view.vm_origin, view.vm_angles = func(wep, origin*1, angles*1) // Note: *1 to copy the object so the child function can't edit it. end local func = wep.CalcView if func then view.origin, view.angles, view.fov = func(wep, pl, origin*1, angles*1, fov) // Note: *1 to copy the object so the child function can't edit it. end end end return view end[/CODE][/QUOTE] And these are the props etc configs, about the player's view and lock rotation combined.. cl_disguise.lua [QUOTE][CODE]include("sh_disguise.lua") local PlayerMeta = FindMetaTable("Player") function PlayerMeta:IsDisguised() return self:GetNWBool("disguised", false) end local function renderDis(self) for k, ply in pairs(player.GetAll()) do if ply:Alive() && ply:IsDisguised() then local model = ply:GetNWString("disguiseModel") if model && model != "" then local ent = ply:GetNWEntity("disguiseEntity") if IsValid(ent) then -- ent:SetNoDraw(false) local mins = ply:GetNWVector("disguiseMins") local maxs = ply:GetNWVector("disguiseMaxs") local ang = ply:EyeAngles() ang.p = 0 ang.r = 0 if ply:DisguiseRotationLocked() then ang.y = ply:GetNWFloat("disguiseRotationLockYaw") end local pos = ply:GetPos() + Vector(0, 0, -mins.z) local center = (maxs + mins) / 2 center.z = 0 center:Rotate(ang) ent:SetPos(pos - center) ent:SetAngles(ang) -- ent:SetupBones() ent:SetSkin(ply:GetNWInt("disguiseSkin", 1)) -- ent:DrawShadow() -- ent:DrawModel() end end else local ent = ply:GetNWEntity("disguiseEntity") if IsValid(ent) then -- ent:SetNoDraw(true) end end end end function GM:RenderDisguises() cam.Start3D( EyePos(), EyeAngles() ) local b, err = pcall(renderDis, self) cam.End3D() if !b then MsgC(Color(255, 0, 0), err .. "\n") end end function GM:RenderDisguiseHalo() local client = LocalPlayer() if client:Team() == 3 then local tr = client:GetPropEyeTrace() if IsValid(tr.Entity) then if tr.HitPos:Distance(tr.StartPos) < 100 then if client:CanDisguiseAsProp(tr.Entity) then local col = Color(50, 220, 50) local hullxy, hullz = tr.Entity:GetPropSize() if !client:CanFitHull(hullxy, hullxy, hullz) then col = Color(220, 50, 50) end halo.Add({tr.Entity}, col, 2, 2, 2, true, true) end end end local tab = {} for k, ply in pairs(player.GetAll()) do if ply != client && ply:Team() == 3 && ply:IsDisguised() then if IsValid(ply.PropMod) then table.insert(tab, ply.PropMod) end end end halo.Add(tab, team.GetColor(3), 2, 2, 2, true, false) end end[/CODE][/QUOTE] sh_disguise.lua [QUOTE][CODE]local PlayerMeta = FindMetaTable("Player") local EntityMeta = FindMetaTable("Entity") local allowClasses = {"prop_physics", "prop_physics_multiplayer"} function PlayerMeta:CanDisguiseAsProp(ent) if !self:Alive() then return false end if self:Team() != 3 then return false end if !IsValid(ent) then return false end if !table.HasValue(allowClasses, ent:GetClass()) then return false end return true end function EntityMeta:IsDisguisableAs() if !table.HasValue(allowClasses, self:GetClass()) then return false end return true end function PlayerMeta:CanFitHull(hullx, hully, hullz) local trace = {} trace.start = self:GetPos() trace.endpos = self:GetPos() trace.filter = self trace.maxs = Vector(hullx, hully, hullz) trace.mins = Vector(-hullx, -hully, 0) local tr = util.TraceHull(trace) if tr.Hit then return false end return true end function EntityMeta:GetPropSize() local hullxy = math.Round(math.Max(self:OBBMaxs().x - self:OBBMins().x, self:OBBMaxs().y - self:OBBMins().y) / 2) local hullz = math.Round(self:OBBMaxs().z - self:OBBMins().z) return hullxy, hullz end function PlayerMeta:GetPropEyePos() if !self:IsDisguised() then return self:GetShootPos() end local angles = self:EyeAngles() local maxs = self:GetNWVector("disguiseMaxs") local mins = self:GetNWVector("disguiseMins") local reach = (maxs.z - mins.z) + 10 local trace = {} trace.start = self:GetPos() + Vector(0, 0, 1.5) trace.endpos = trace.start + Vector(0, 0, reach + 5) local tab = ents.FindByClass("prop_ragdoll") table.insert(tab, self) trace.filter = tab local tr = util.TraceLine(trace) return trace.start + (trace.endpos - trace.start):GetNormal() * math.Clamp(trace.start:Distance(tr.HitPos) - 5, 0, reach) end function PlayerMeta:GetPropEyeTrace() if !self:IsDisguised() then local tr = self:GetEyeTraceNoCursor() local trace = {} trace.start = tr.StartPos trace.endpos = trace.start + self:GetAimVector() * 100000 trace.filter = self trace.mask = MASK_SHOT return util.TraceLine(trace) end local maxs = self:GetNWVector("disguiseMaxs") local mins = self:GetNWVector("disguiseMins") local trace = {} trace.start = self:GetPropEyePos() trace.endpos = trace.start + self:GetAimVector() * 100000 trace.filter = self trace.mask = MASK_SHOT local tr = util.TraceLine(trace) return tr end local function checkCorner(mins, maxs, corner, ang) corner:Rotate(ang) mins.x = math.min(mins.x, corner.x) mins.y = math.min(mins.y, corner.y) maxs.x = math.max(maxs.x, corner.x) maxs.y = math.max(maxs.y, corner.y) end function PlayerMeta:CalculateRotatedDisguiseMinsMaxs() local maxs = self:GetNWVector("disguiseMaxs") local mins = self:GetNWVector("disguiseMins") local ang = self:EyeAngles() ang.p = 0 local nmins, nmaxs = Vector(0, 0, mins.z), Vector(0, 0, maxs.z) checkCorner(nmins, nmaxs, Vector(maxs.x, maxs.y), ang) checkCorner(nmins, nmaxs, Vector(maxs.x, mins.y), ang) checkCorner(nmins, nmaxs, Vector(mins.x, mins.y), ang) checkCorner(nmins, nmaxs, Vector(mins.x, maxs.y), ang) -- print(mins, maxs, nmins, nmaxs) return nmins, nmaxs end function PlayerMeta:DisguiseRotationLocked() return self:GetNWBool("disguiseRotationLock") end[/CODE][/QUOTE] sv_disguise.lua [QUOTE][CODE]include("sh_disguise.lua") local PlayerMeta = FindMetaTable("Player") local EntityMeta = FindMetaTable("Entity") function GM:PlayerDisguise(ply) if ply:Team() == 3 then local tr = ply:GetPropEyeTrace() if IsValid(tr.Entity) then if tr.HitPos:Distance(tr.
No one? :(
none of these have CalcView in them - they aren't the right files
Actually, this prop hunt may use : function PlayerMeta:GetPropEyePos() for finding the position to set the cam at. But, yes, CalcView would be what ultimately controls it.
ok i'm dumb, i thought there was no calcview in the configs, because i didn't find it, but guess i missed this one.. so yeah here is the calcview that i dont like :/ so it's this one i don't know how to edit or what to edit to make it 3rd person and not those ugly camera angles :s help plz :( Edit: and no, simply replacing this "CalcView" by the other won't work, yes it's dumb, and yes i tried xD but no, it doesn't change anything.. xD just saying :p [QUOTE][CODE] function GM:CalcView(ply, pos, angles, fov) if self:IsCSpectating() && IsValid(self:GetCSpectatee()) then ply = self:GetCSpectatee() end if ply:IsPlayer() && !ply:Alive() then ply = ply:GetRagdollEntity() end if IsValid(ply) then if ply:IsPlayer() && ply:IsDisguised() then local maxs = ply:GetNWVector("disguiseMaxs") local mins = ply:GetNWVector("disguiseMins") local view = {} local reach = (maxs.z - mins.z) local trace = {} trace.start = ply:GetPropEyePos() trace.endpos = trace.start + angles:Forward() * -(reach + 5) local tab = ents.FindByClass("prop_ragdoll") table.insert(tab, ply) trace.filter = tab local tr = util.TraceLine(trace) view.origin = trace.start + (trace.endpos - trace.start):GetNormal() * math.Clamp(trace.start:Distance(tr.HitPos) - 5, 0, reach) view.angles = angles view.fov = fov return view end end end [/CODE][/QUOTE]
Change: [code]trace.start = ply:GetPropEyePos()[/code] To: [code]trace.start = ply:GetEyePos()[/code] That should select the player eyes although I'm not sure if the model changes the position. If it does then use something like this: [code]trace.start = ply:LocalToWorld( Vector( 0, 0, ( ply:Crouching( ) && 36 || 72 ) ) );[/code] If the player is crouching, the eyes are typically 36 units up. Otherwise around 72. LocalToWorld converts a "localized" position to the actual world position based on the parent entity GetPos so it is the same as: [code]trace.start = ply:GetPos( ) + Vector( 0, 0, ( ply:Crouching( ) && 36 || 72 ) );[/code]
Well when i simply changed to [CODE]trace.start = ply:GetEyePos()[/CODE] it didn't gave me Lua Errors instantly, but when I became a prop, Lua Errors came and the player view was still the same, and the error was about the "GetEyePos" but this code.. [CODE]trace.start = ply:GetPos( ) + Vector( 0, 0, ( ply:Crouching( ) && 36 || 72 ) );[/CODE] it worked!! well kinda, it's way better, but there's still one thing to fix :/ it's not really in 3rd person, it's just keeps in the "normal eyes" of a player.. and because of that it has some weird effects and bugs :/ for example, I should be able to see myself all the time, like move with the camera, like the prop was the "center", and my camera just kinda get's locked in the prop as a "center", and i look around like in a "orbit" to the prop xD.. idk if im making myself understand.. basically in 3rd person.. xD you know what I mean i think.. and this is what it's like now (im a cup) when I look forward [IMG]http://s30.postimg.org/yvm5jcypd/normaleyes.jpg[/IMG] and i can look down, and look like this.. xD [IMG]http://s12.postimg.org/6ijcoxwz1/lookdown.jpg[/IMG] and then when im trying to become other props after transformed is way harder, because i think that where my crosshair is pointing doesn't correspond to where i'm actually pointing.. for example if I looked directly to a prop it should get green saying i could transform on that prop, but to be able to look exactly to the prop i have to look somewhere else further or something like that O.o for example in this image, if i look directly it doesnt get green, and only if I look to it this way.. [IMG]http://s14.postimg.org/uj8dkdvht/doesntfitcrosshair.jpg[/IMG] Help :/
We just need to move the camera backwards. We can use a normalized vector to get the Forward direction of the player, then multiply by - units. I do have an example of a 3rdperson camera which lets you look at the player and rotate around using the mouse in addition to looking up and down. I need to simplify it because right now it uses my Get/SetFlag system and it isn't fully out, but until then lets fix yours... The part that controls moving back is already there, but it only moves back a small amount, not near enough to be high up in the air for smaller props. We could simply get a difference so the difference in height is how much we move backwards ( may need to double it ). Then we add that to the multiplier (reach + 5) to move it back that amount. Additionally we want to make sure it doesn't go through the wall, but there is already a trace so it should be fine. So.. Replace: [code] local trace = {} trace.start = ply:GetPos( ) + Vector( 0, 0, ( ply:Crouching( ) && 36 || 72 ) ); trace.endpos = trace.start + angles:Forward() * -(reach + 5)[/code] With: [code] local height = ( ply:Crouching( ) && 36 || 72 ); local buffer = 5; local height_offset = height - ( reach + buffer ) trace.start = ply:LocalToWorld( Vector( 0, 0, height ) ); trace.endpos = trace.start + angles:Forward() * -( reach + buffer + ( height_offset * 2 ) ) [/code]
[QUOTE=NuKeRGG;46701324] [code] function GM:CalcView(ply, pos, angles, fov) if self:IsCSpectating() && IsValid(self:GetCSpectatee()) then ply = self:GetCSpectatee() end if ply:IsPlayer() && !ply:Alive() then ply = ply:GetRagdollEntity() end if IsValid(ply) then if ply:IsPlayer() && ply:IsDisguised() then local maxs = ply:GetNWVector("disguiseMaxs") local mins = ply:GetNWVector("disguiseMins") local view = {} local reach = (maxs.z - mins.z) local trace = {} trace.start = ply:GetPropEyePos() trace.endpos = trace.start + angles:Forward() * -(reach + 5) local tab = ents.FindByClass("prop_ragdoll") table.insert(tab, ply) trace.filter = tab local tr = util.TraceLine(trace) view.origin = trace.start + (trace.endpos - trace.start):GetNormal() * math.Clamp(trace.start:Distance(tr.HitPos) - 5, 0, reach) view.angles = angles view.fov = fov return view end end end [/code] [/QUOTE] all you gotta do is change [code] local reach = (maxs.z - mins.z) [/code] to [code] local reach = math.max(36, maxs.z - mins.z) [/code] & @Acecool please stop making things so complicated while not even following your lua grammar standards
I edited someone elses code so I used their standards. If I rewrite something or write it from scratch I use mine. Mine isn't complicated, yours doesn't even include the height fix.
So... Acecool, I did what you asked and it gave me lua errors about the trace when i transformed into a prop :/ And... MeepDarknessM, i did your simple thing, and well, it worked like as I wanted too thanks :p even thought i changed the "32" value to 135 because in bigger props our view would be too close to it, so the final code is like this.. [CODE]function GM:CalcView(ply, pos, angles, fov) if self:IsCSpectating() && IsValid(self:GetCSpectatee()) then ply = self:GetCSpectatee() end if ply:IsPlayer() && !ply:Alive() then ply = ply:GetRagdollEntity() end if IsValid(ply) then if ply:IsPlayer() && ply:IsDisguised() then local maxs = ply:GetNWVector("disguiseMaxs") local mins = ply:GetNWVector("disguiseMins") local view = {} local reach = math.max(135, maxs.z - mins.z) local trace = {} trace.start = ply:GetPropEyePos() trace.endpos = trace.start + angles:Forward() * -(reach + 5) local tab = ents.FindByClass("prop_ragdoll") table.insert(tab, ply) trace.filter = tab local tr = util.TraceLine(trace) view.origin = trace.start + (trace.endpos - trace.start):GetNormal() * math.Clamp(trace.start:Distance(tr.HitPos) - 5, 0, reach) view.angles = angles view.fov = fov return view end end end[/CODE] with this result [IMG]http://s7.postimg.org/dq52t6q3f/finally1.jpg[/IMG] [IMG]http://s22.postimg.org/so5r3uzn5/finally2.jpg[/IMG] Thanks Acecool for your help, I even learned something with you, and thanks MeepDarknessM for giving the solution :p and for kinda make me feel dumb for how simple it was.. aha xD
Sorry, you need to Log In to post a reply to this thread.