• CalcView Pauses with FA:S2 + GetBonePosition
    1 replies, posted
So I know this sounds like a very specific question with a very specific answer that would require a lot of code-surfing to find an answer to, so I'm gonna try my best to generalize the issue. I've been attempting to use the CalcView hook to place the player's viewport (i guess) where the playermodel's head is. I am doing this by function GAMEMODE:CalcView( ply, pos, angles, fov ) local view = {} view.origin = ply:GetBonePosition( ply:LookupBone( "ValveBiped.Bip01_Head1" ) ) view.angles = angles view.fov = fov view.drawviewer = ply:InVehicle() if ply:InVehicle() then view.fov = 70 ply:ManipulateBoneScale( ply:LookupBone( "ValveBiped.Bip01_Head1" ), Vector() ) end return view end Never mind about GM/GAMEMODE, that's not the issue right now. So this works perfectly, the view is where it should be, so I moved on to editing the FA:S2 weapon base to change the bullet origin. This is where the problems start. Whenever the weapon references ply:GetBonePosition( ply:LookupBone( "ValveBiped.Bip01_Head1" ) ) the CalcView seems to pause for a few frames. Now I don't mean the whole game freezes, because it doesn't, only the view position just fails to update for a few frames. If I enable drawviewer, I can see the back of my model's head for less than a second. This issue happens both when actually firing a bullet, and when testing if a bullet can be fired (nearwall, mag, etc.) The issue only happens when trying to adjust the bullet source to a bone position, any other position doesn't cause a stutter. This only happens with the FA:S2 base, but I'm hoping this can be answered in a way not specific to FA:S2. The hook still runs while this "pausing" occurs, because adding a print statement testing the previous position to the current position will successfully print. Is there something with GetBonePosition in conjunction with some other function and CalcView that causes the CalcView hook to use the previous location? Or is there a better reason to accomplish the goal I'm reaching? Thanks for reading, and I hope someone knows a solution!
Fixed, for anyone else who might stumble upon this issue, use Player:GetAttachment( Player:LookupAttachment( "anim_attachment_head") ).Pos as the source of the bullet instead of the bone position. For some reason that works.
Sorry, you need to Log In to post a reply to this thread.