• Changing weapon rendering position
    6 replies, posted
So, I was wondering if it is possible to change the rendering origin of a world entity of a weapon to somewhere else? The reason I ask is because I'd like to be able to make a player have the models/kleiner.mdl model and have all their weapons at their crotch. Is there any way to do this? Perhaps someone knew why this happened in the first place and I can make it happen again via Lua? Thanks.
[url=http://www.facepunch.com/showpost.php?p=18299985&postcount=4]Link[/url] That's how I would go about doing it.
[QUOTE=Nori;18442788]So, I was wondering if it is possible to change the rendering origin of a world entity of a weapon to somewhere else? The reason I ask is because I'd like to be able to make a player have the models/kleiner.mdl model and have all their weapons at their crotch. Is there any way to do this? Perhaps someone knew why this happened in the first place and I can make it happen again via Lua? Thanks.[/QUOTE] Crotch weapons? If you want to replicate a weapon having no world model bones then it's even simpler! Make it so that their weapon's world model doesn't s how and spawn a prop_dynamic that you nocollide/noshadow/noeverything then position at crouch level on the player. Then parent it to the player.
[lua] function SWEP:DrawWorldModel( ) if not ValidEntity( self.Owner ) then self:DrawModel( ) return end self:SetRenderOrigin( self.Owner:GetPos( ) + Vector( 0, 0, 36 ) ) self:SetRenderAngles( self.Owner:GetAngles( ) ) self:DrawModel( ) end [/lua] Untested, but something like that I think.
[QUOTE=Kogitsune;18443144][lua] function SWEP:DrawWorldModel( ) if not ValidEntity( self.Owner ) then self:DrawModel( ) return end self:SetRenderPosition( self.Owner:GetPos( ) + Vector( 0, 0, 36 ) ) self:setRenderAngles( self.Owner:GetAngles( ) ) self:DrawModel( ) end [/lua] Untested, but something like that I think.[/QUOTE] I've never heard of these functions!! But they look exactly like what I need. Can you confirm that these exist? The wiki could use their addition. :3: Oh and on topic I'm pretty sure Nori means to do this to any and all weapons, even non scripted ones?
[url=http://wiki.garrysmod.com/?title=SWEP.DrawWorldModel]SWEP.DrawWorldModel[/url] [url=http://wiki.garrysmod.com/?title=Entity.SetRenderAngles]Entity.SetRenderAngles[/url] [url=http://wiki.garrysmod.com/?title=Entity.SetRenderOrigin]Entity.SetRenderOrigin[/url] All three exist on the wiki ( but the two entity functions aren't filled in ). You can see the source for them [url=http://luabin.foszor.com/code/lua/includes/extensions/entity_cl.lua]here[/url] - they're just AccessorFuncs that I think the rest of the code interacts with. Of course, the first one only works on SWEPs, but you could creatively work around that by using an effect with a model ( or a ClientsideModel ), hiding the player's actual weapon world model with Player.DrawWorldModel( false ), and drawing the effect's model wherever you wanted it to be. I do this myself in a gamemode that is played top-down, since hiding the weapon's world model stops the player from drawing correctly for some reason.
[QUOTE=Kogitsune;18443277][url=http://wiki.garrysmod.com/?title=SWEP.DrawWorldModel]SWEP.DrawWorldModel[/url] [url=http://wiki.garrysmod.com/?title=Entity.SetRenderAngles]Entity.SetRenderAngles[/url] [url=http://wiki.garrysmod.com/?title=Entity.SetRenderOrigin]Entity.SetRenderOrigin[/url] All three exist on the wiki ( but the two entity functions aren't filled in ). You can see the source for them [url=http://luabin.foszor.com/code/lua/includes/extensions/entity_cl.lua]here[/url] - they're just AccessorFuncs that I think the rest of the code interacts with. Of course, the first one only works on SWEPs, but you could creatively work around that by using an effect with a model ( or a ClientsideModel ), hiding the player's actual weapon world model with Player.DrawWorldModel( false ), and drawing the effect's model wherever you wanted it to be. I do this myself in a gamemode that is played top-down, since hiding the weapon's world model stops the player from drawing correctly for some reason.[/QUOTE] Oh, clientside functions, of course. I was looking serverside for some reasons. :v: And yeah for this purpose what you've proposed seems like the best solution.
Sorry, you need to Log In to post a reply to this thread.