• Parenting a clientside model to your head
    24 replies, posted
Basically, the title, i'm kinda stuck, i've made the model fine, set it's angles and set it's position, but whenever i parent it, it rotates around the feet of my player.
Anyone?
-snip-
Disable the normal rendering ( cmodel:SetNoDraw( true ) ). Set the position and angles yourself ( cmodel:SetPos( vec ), cmodel:SetAngles( ang ) ). Tell it to render ( cmodel:DrawModel( ) ). That's how I do it and it works for me.
-snip-
Yeah, i don't think you understand(no offence), so heres a video of where it all goes wrong [media]www.youtube.com/watch?v=yBg4X-09vko[/media] (There are so many barrels from the different attempts, all result in the same pivot-around-base effect.) These media tags hate me
Looks like you got a problem putting them into position [editline]07:03PM[/editline] You can just screw parenting and use SetPos and SetAngles as Kogitsune, lookup bones on the wiki
The head has boneID 6 on playermodels:angel:
Bah. I'm confused :c. I set its pos and shiz without parenting it and it spawns, and doesn't move with the player :C bawww
Try calling :SetupBones() between positioning it and drawing it.
Yep, same error, doesn't move with the player.
Wait, you're doing it in a renderhook right? D:
Wait what. What's a renderhook? :c I'm useless. I got it working by using a think hook, but it likes to lag behind my player when i run.
Show us some code and we might be able to help
I don't really need help with the code now, I'm just wondering what a render hook is.
It's where rendering is done:downs: "PostDrawOpaqueRenderables" is a good hook to use imo, try it instead of think and it shouldn't lag behind:3:
Don't you mean "shouldn't"? :c
[QUOTE=decyg;22045984]Don't you mean "shouldn't"? :c[/QUOTE] I wrote that:ninja:
Lagging behind again >:C Code [lua] LocalPlayer().Hat = "models/Combine_Helicopter/helicopter_bomb01.mdl" hat = ents.Create("prop_physics") hat.Owner = LocalPlayer() hat:SetModel(LocalPlayer().Hat) hat:SetNoDraw(true) hook.Add("PostDrawOpaqueRenderables","kay",function() attp, atta = LocalPlayer():GetBonePosition( 6 ) attp, atta = LocalToWorld( Vector(10,0,0), Angle(0,90,90), attp, atta ); hat:SetPos( attp ) hat:SetAngles(atta) hat:SetNoDraw(false) end) [/lua]
Anyone?
Set the position clientside in ENT.Draw
Not tested ( since I don't have the actual code with me ), but this is close to what I used to do this: [hd]http://www.youtube.com/watch?v=De7t2SUW-iA[/hd] [lua]local hats = { } local function CreateHat( pl, model ) SafeRemoveEntity( pl.Hat ) local hat hat = ClientsideModel( model, RENDERGROUP_OPAQUE ) hat:SetNoDraw( true ) pl.Hat = hat hat.Owner = pl table.insert( hats, hat ) end local function CleanHats( ) local k, v for k, v in pairs( hats ) do if not ValidEntity( v ) then hats[ k ] = nil elseif not ValidEntity( v.Owner ) then SafeRemoveEntity( v ) hats[ k ] = nil end end end local function DrawHats( ) local k, v, pos, ang CleanHats( ) for k, v in ipairs( player.GetAll( ) ) do if not v:Alive( ) and ValidEntity( v.Hat ) then SafeRemoveEntity( v.Hat ) v = v:GetRagdollEntity( ) end if not ValidEntity( v.Hat ) then CreateHat( v, "models/combine_helictoper/helicopter_bomb01.mdl" ) end pos, ang = v:GetBonePosition( 6 ) v.Hat:SetPos( pos ) v.Hat:SetAngles( ang ) v.Hat:DrawModel( ) end end hook.Add( "PostDrawOpaqueRenderables", "Draw Hats.PostDrawOpaqueRenderables", DrawHats )[/lua]
I will be sure to check that out Kogitsune, thanks for the snippet! |FlapJack| I think you misunderstood, i'm not creating a custom entity and doing stuff, i'm creating a clientside prop and doing stuff.
You would be better off using a custom entity.
Meh.
Sorry, you need to Log In to post a reply to this thread.