[t]http://filesmelt.com/dl/2014-01-03_000021.jpg[/t]
I want to attach this riot shield to player's head, but
[code]self.ent:Fire("SetParentAttachmentMaintainOffset", "ValveBiped.Bip01_Head1")[/code]
Didn't work, so is there any alternative?
I've got viewmodel for looks, and I want it to actually block bullets.
[QUOTE=Handsome Matt;43401625]Ah, try messing with:
ent:SetLocalAngles( Angle(0, 0, 0) )
ent:SetLocalPos( Vector(0, 0, 0) )
These set the position of your entity relative to their parent, you might also experience some draw bugs maybe where the entity refuses to move in time with the player, if that happens you'll want to look into manually drawing the entity.[/QUOTE]
You could have both, so an invisible shield blocks the bullets and an identical rendered shield clientside prop looks good visually, so the clientside prop acts as a kind of prediction. Seems like it would get a lot of latency bugs with the collision though.
I ended up using PostDrawOpaqueRenderables hook with a ClientsideModel.
I solved rotation by using RotateAroundAxis.
[CODE]local Example = ClientsideModel( MDL_GOES_HERE, RENDERGROUP_OPAQUE )
local backBone = ply:LookupBone("ValveBiped.Bip01_Spine2")
local bonePos, boneAng = ply:GetBonePosition( backBone )
boneAng:RotateAroundAxis(boneAng:Up(), 70)
boneAng:RotateAroundAxis(boneAng:Right(), 150)
boneAng:RotateAroundAxis(boneAng:Forward(), 260)
Example:SetPos( bonePos + Vector(0,0,10) )
Example:SetAngles( boneAng )
Example:DrawModel()[/CODE]
That would work if I replace the last line with some of my code, thanks.
[t]http://filesmelt.com/dl/2014-01-04_00001.jpg[/t]
Now it just spawns shield prop.
Here be code.
[code]function SWEP:Deploy( pos, ang )
if SERVER then
self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
timer.Simple( 0.5, function()self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)end)
if IsValid(self.ent) then return end
self:SetNoDraw(true)
self.ent = ents.Create("prop_physics")
self.ent:SetModel("models/weapons/CZ/w_shield.mdl", RENDERGROUP_OPAQUE)
local ply = self.Owner
local backBone = ply:LookupBone("ValveBiped.Bip01_Head1")
local bonePos, boneAng = ply:GetBonePosition( backBone )
boneAng:RotateAroundAxis(boneAng:Up(), 70)
boneAng:RotateAroundAxis(boneAng:Right(), 150)
boneAng:RotateAroundAxis(boneAng:Forward(), 260)
self.ent:SetPos( bonePos + Vector(0,0,10) )
self.ent:SetAngles( boneAng )
self.ent:SetCollisionGroup( COLLISION_GROUP_WORLD )
self.ent:Spawn()
self.ent:Activate()
end
return true
end[/code]
How so?
ERROR: Tried to SetParentAttachment for entity player (player), but it has no parent.
-snip-
[editline]5th January 2014[/editline]
[QUOTE=Handsome Matt;43412798]Nowhere in the updated code did it mention 'SetParentAttachment', so post the code you're trying to use that's giving you that error.[/QUOTE]
Fixed it already.
Now the shield changes its position depending on player look ( I've attached it to Spine2)
[t] http://filesmelt.com/dl/2014-01-04_000021.jpg[/t]
[t] http://filesmelt.com/dl/2014-01-04_000031.jpg[/t]
[t] http://filesmelt.com/dl/2014-01-04_000041.jpg[/t]
The problem is, the shield position changes on re-equipping weapon. And I've tried setting it to different bones.
Sorry, you need to Log In to post a reply to this thread.