Hi,
Basically I want the view of the player always in front of him but I don't really know how to do that (I've some issues with the angles)
I've done that so far :
[CODE]local function CamFront( ply, pos, angles, fov )
local view = {}
local CamPos= angles:Forward()*100
view.origin = pos+ ( Vector(-CamPos.x,CamPos.y,-3) )
view.angles = -Angle(0,angles.y,0)
view.fov = fov
view.drawviewer = true
return view
end
hook.Add( "CalcView", "MyCalcView", CamFront)
[/CODE]
but this gave me this result:
[video=youtube;Q4i1MVMIHb4]https://www.youtube.com/watch?v=Q4i1MVMIHb4[/video]
Do you have any idea of how doing it ?
Video is private
[QUOTE=smithy285;51799507]Video is private[/QUOTE]
Whooops
You should use the angle of the vector 'CamPos': [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Vector/Angle]Vector:Angle[/url]
Something like:
[code]
view.angles = CamPos:Angle()
[/code]
But i don't understand what you want exactly.
When you say "view of players always in front of him", it is in front of his head (so using the up/down axis) or in front of his 'torso' ?
[QUOTE=guigui;51799724]You should use the angle of the vector 'CamPos'
[/QUOTE]
I tried but it does the exact same thing :s
[QUOTE=guigui;51799724]
But i don't understand what you want exactly.
When you say "view of players always in front of him", it is in front of his head (so using the up/down axis) or in front of his 'torso' ?[/QUOTE]
More like he holds a selfi stick
Then simply place the camera in front of the player face
[code]
local camPos = angles:Forward() * 100 // Get the vector 100 unit away of the player face
view.origin = pos + camPos // Add it to the player shoot pos
[/code]
And revert the angle, because the phone look at the invert of the player
[code]
view.angles = -angles // Invert the angle, like he have eyes behind his head
[/code]
ps: not tested, but it should give you enough to fix it
Sorry, you need to Log In to post a reply to this thread.