I want to make a command for thirdperson, that any player can use.
e.g.
'say !thirdperson'
'say !firstperson'
Or maybe even a little derma screen that you can switch between modes.
Is there something like this around that I can just add to my gamemode?
[lua]
local ThirdPerson = false
function MyCalcView(ply, pos, angles, fov)
if(ThirdPerson) then
local view = {}
view.origin = pos-(angles:Forward()*150)
view.angles = angles
view.fov = fov
return view
end
end
hook.Add("CalcView", "MyCalcView", MyCalcView)
hook.Add("ShouldDrawLocalPlayer", "ShouldDrawLocalPlayer", function(ply)
return ThirdPerson
end)
concommand.Add("Third_Person", function() ThirdPerson = true end)
concommand.Add("First_Person", function() ThirdPerson = false end)
[/lua]
Third_Person or First_Person in your console :)
By the way this is a Clientside script, so save it somewhere like lua\autorun\client\Thirdperson.lua and in a serverside script run AddCSLuaFile on it.
This is great!
Coupled with a little derma window this works fantastic, thanks mate :smile:
I'm not.. entirely sure how this works (mostly just the actual changing of the view,
[CODE]
local view = {}
view.origin = pos-(angles:Forward()*150)
view.angles = angles
view.fov = fov
[/CODE]
I don't know where any of these variables come from .. origin, pos, angles, fov... I'm assuming they're built in variables. I'm trying to use this to force clients to be in third person.. however, as is, the camera is still too close to the back of their head. The camera will often move into the model and it looks strange. Also the camera is offset to the left a bit, almost as though I'm looking over the shoulder. How can this be modified to be more like the built in "thirdperson"?
Theyre from the hook :P, change the *150 to be greater for a further back view, like *300 is quite good, you could even make that customizable in the console command.
Ill just make something so its a bit further right, ah yes, if you move the camera the aim position will then be off the crosshair, but you can still zoom out further
[lua] view.origin = pos-(angles:Forward()*200) [/lua] Is quite close to the thirdperson command
Ah so I can make a third concvar that uses 'over the shoulder' view, awesome :)
[QUOTE=LODY;22577330]Ah so I can make a third concvar that uses 'over the shoulder' view, awesome :)[/QUOTE]
Without a doubt yes. Check out [url=http://www.facepunch.com/member.php?u=190368][b]AnnoyedTree's[/b][/url] [url=http://www.facepunch.com/showthread.php?t=849535][b]laststand[/b][/url] gamemode his is a over the shoulder 3rd person zombie shooter.
He uses hooks and usmg's for it which is pretty sweet. Because you can create events in which it can be called.
[QUOTE=Willox;22573353]Theyre from the hook :P, change the *150 to be greater for a further back view, like *300 is quite good, you could even make that customizable in the console command.
Ill just make something so its a bit further right, ah yes, if you move the camera the aim position will then be off the crosshair, but you can still zoom out further
view.origin = pos-(angles:Forward()*200) Is quite close to the thirdperson command[/QUOTE]
In changing that, I see no difference. I think I'm doing something else wrong. I'm gonna keep tweaking it, but here's what I currently have:
[CODE]function MyCalcView(ply, pos, angles, fov)
local view = {}
view.origin = pos-(angles:Forward()*200)
view.angles = angles
view.fov = fov
end
hook.Add("CalcView", "MyCalcView", MyCalcView) local view = {} [/CODE]
Even at 900, the camera is RIGHT in back of the model's head.
Mine wasnt that close, you probably have another conflicting script
[QUOTE=Willox;22587822]Mine wasnt that close, you probably have another conflicting script[/QUOTE]
Hmm. I don't have anything else having to do with the camera. And without the script it's normal first person.
OK! Stupid mistake on my part. But there's still a problem. When in third person, when looking at an entity, my weapon disappears.
[IMG]http://img.photobucket.com/albums/v600/JTG2003/Untitled-10.png[/IMG]
(There should be a crowbar there. It's there when my crosshair isn't on the target
Sorry, you need to Log In to post a reply to this thread.