• Weapon W Model Centered Instead of in hands
    12 replies, posted
[lua]-- Read the weapon_real_base if you really want to know what each action does if SERVER then AddCSLuaFile("shared.lua") SWEP.HoldType = "smg" end if CLIENT then SWEP.PrintName = "COLT M16" SWEP.Slot = 3 SWEP.SlotPos = 1 SWEP.IconLetter = "b" SWEP.ViewModelFlip = false SWEP.ViewModelFlip = false SWEP.Category = "Spitfire Guns" killicon.AddFont("weapon_real_cs_ak47", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) ) end SWEP.EjectDelay = 0.05 SWEP.Instructions = "Small Damage Full Auto/Single (Switch by E+Right Click)" SWEP.Base = "weapon_real_base_rifle" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.ViewModel = "models/weapons/v_rif_m16a1.mdl" SWEP.WorldModel = "models/weapons/w_rif_m16a1.mdl" SWEP.Primary.Sound = Sound("weapons/m16a1/m16a1-1.wav") SWEP.Primary.Recoil = 0.5 SWEP.Primary.Damage = 15 SWEP.Primary.NumShots = 1 SWEP.Primary.Cone = 0.017 SWEP.Primary.ClipSize = 20 SWEP.Primary.Delay = 0.1 SWEP.Primary.DefaultClip = 20 SWEP.Primary.Automatic = true SWEP.Primary.Ammo = "smg1" SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" SWEP.IronSightsPos = Vector (-3.78, -4.641, 1.177) SWEP.IronSightsAng = Vector (0, 0, 0) [/lua] getting this: [URL=http://img143.imageshack.us/i/holdtype.png/][IMG]http://img143.imageshack.us/img143/9168/holdtype.png[/IMG][/URL] Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]
Weapon model needs to have those things so enigne understands to put it. I can't remember how it was called. You don't have those. Also, It is possible with lua, but I have no idea how.
The model doesn't have proper attachments. [editline]13th November 2010[/editline] ninja'd:ninja:
how can i fix it?
Either give the model an attachment in a modelling program or position a fake model into the hands manually through Lua (though I don't think you're at the level of being able to do that seeing as your SWEP has no functions what so ever)
what do you mean by attachment? Eotech? Aimpoint?
An attachment is a reference point on a model used for positioning different things. Chances are the model you are using wasn't made to be a held weapon, so like ralle said, you're either gonna have to manually do it (which can be a pain in the ass), or find a different model. (Also, you should fix the weapon holdtype) [lua] function SWEP:Initialize() self:SetWeaponHoldType(self.HoldType) end [/lua]
but the model i found was in FPS banana (CS:S) and were do i put that Lua Command? and its should support Source
Seems as if you just copy and pasted some things, seeing you don't know what do to. Like at all. "-- Read the weapon_real_base if you really want to know what each action does" I'm sure you didn't add that. I could be wrong, but I'm entitled to my opinion.
[QUOTE=Willsmith190;26066099]Seems as if you just copy and pasted some things, seeing you don't know what do to. Like at all. "-- Read the weapon_real_base if you really want to know what each action does" I'm sure you didn't add that. I could be wrong, but I'm entitled to my opinion.[/QUOTE] :irony: You broke my irony meter :<
It appears I have done just that :P Tape was invented for a reason :)
Weapons are placed in the hands of the player model through something called bone merge. The bones for CSS world models are not the same as the HL2 ones, and I'm pretty certain they are not the same length name either, so I don't think you can hex it to fix it. Although, thankfully, you can fix this with Lua. [code] SWEP.Offset = { Pos = { Up = 0, Right = 0, Forward = 0, }, Ang = { Up = 0, Right = 0, Forward = 0, } } function SWEP:DrawWorldModel( ) local hand, offset, rotate if not ValidEntity( self.Owner ) then self:DrawModel( ) return end if not self.Hand then self.Hand = self.Owner:LookupAttachment( "anim_attachment_rh" ) end hand = self.Owner:GetAttachment( self.Hand ) if not hand then self:DrawModel( ) return end offset = hand.Ang:Right( ) * self.Offset.Pos.Right + hand.Ang:Forward( ) * self.Offset.Pos.Forward + hand.Ang:Up( ) * self.Offset.Pos.Up hand.Ang:RotateAroundAxis( hand.Ang:Right( ), self.Offset.Ang.Right ) hand.Ang:RotateAroundAxis( hand.Ang:Forward( ), self.Offset.Ang.Forward ) hand.Ang:RotateAroundAxis( hand.Ang:Up( ), self.Offset.Ang.Up ) self:SetRenderOrigin( hand.Pos + offset ) self:SetRenderAngles( hand.Ang ) self:DrawModel( ) end [/code] Just tinker with the values of Pos and Ang until it looks about right. It's not really an ideal solution, but it is easier than recompiling models.
Oh, cool, I had this issue, but I didn't want to ask because it wasn't a huge issue. So, atleast I have the code if I ever need it :D
Sorry, you need to Log In to post a reply to this thread.