• [HELP] Is there a way to get a players forward velocity. (No matter what the angle)
    4 replies, posted
Hi Guys. Im looking for a way to get the Local Players forward velocity returned as one number instead of a vector. ( So the box in the video will only move up and down ) Is this possible? I had a play with this code below and the video below was the result. Any Suggestions?? [CODE]function draw_HUD() -- Everything will be parented to this. hud_frame = vgui.Create("DPanel") hud_frame:SetSize( ScrW(), ScrH() ) hud_frame.Think = function() vel_x = LocalPlayer():GetVelocity().x vel_y = LocalPlayer():GetVelocity().y vel_z = LocalPlayer():GetVelocity().z hud_frame:SetPos( 0 + vel_x , 0 + vel_y ) end hud_frame.Paint = function() end test_box = vgui.Create("DPanel", hud_frame) test_box:SetSize( 300, 300 ) test_box:SetPos( (ScrW()/2) - 150, (ScrH()/2) - 150 ) test_box.Paint = function(self) draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 255 ) ) end end[/CODE] [video=youtube;pt67m6WN2PI]http://www.youtube.com/watch?v=pt67m6WN2PI[/video]
Unless you [I]only[/I] want the forwards velocity (not sideways), but I don't think you want that even though your title suggests it, then this is the way to go: [lua]local speed = LocalPlayer():GetVelocity():Length()[/lua]
player:GetVelocity():Length() [url]http://wiki.garrysmod.com/page/Entity/GetVelocity[/url] [url]http://wiki.garrysmod.com/page/Vector/Length[/url] [editline]1 September 2014[/editline] fucking ninja'd
[QUOTE=ZombieWizzard;45860316]fucking ninja'd[/QUOTE] pleb
Thanks Guys... Got what i needed. Although Tommy228 contacted me suggesting i tie moving the box around to player movement binds which would also suit. However i can use this variable to keep the movement animations in sync.
Sorry, you need to Log In to post a reply to this thread.