• Getting GetViewModelPosition to work with CalcView
    7 replies, posted
Hello, it's Storm again with another question. I have been trying to find what information I could about getting SWEP:CalcView() to work with SWEP:GetViewModelPosition(). I can confirm that Both functions work fine on their own. I have swept through about every little bit of info I can find about getting these two to work together, but I've been unsuccessful in getting them to work together. From what I've seen/heard it is a simple fix/hack so I feel a bit dumb for asking. Thank you for the help!
What are you trying to do? Also, there's this hook: [url]http://wiki.garrysmod.com/page/WEAPON/CalcViewModelView[/url]
I am using GetViewModelPosition to modify the weapon's position/angles for ironsights, running/walking weapon bob animations, and weapon sway. I am using Calcview to modify the player's angle based on the weapon's attachment position/angle so the player's camera angle changes when he reloads. That and so I could smooth out the FOV transition when the weapon goes to the ironsight position. Also, thank you for that hook, I was not aware they had another hook you can use other than GetViewModelPosition.
You will have to do each of those things in their separate hooks. A hacky method would be to make local variable(s) outside of any hooks ( Or variable(s) assigned to SWEP table ), set their values in one hook, and use their values in other.
[quote=Robotboy655]You will have to do each of those things in their separate hooks[/quote] I'm not quite sure what you mean. When I meant these hooks work on their own, I meant that only one will work when the other isn't being used in my weapon base. When I use CalcView, GetViewModelPosition stops working and won't even attempt to move the model. I don't really need information sent from one hook to another if that is what you meant. Sorry if I didn't clarify correctly.
I did this by doing [lua] local f = weapon.Get(wep:GetClass()).GetViewModelPosition local vmang, vmpos = f(wep) f(wep, vmang, vmpos) view.vm_angles = vmang view.vm_pos = Campos return view [/lua] or something similar, I'll write back later when I'm on my computer
[QUOTE=Stormtrooper595;44159817]I'm not quite sure what you mean. When I meant these hooks work on their own, I meant that only one will work when the other isn't being used in my weapon base. When I use CalcView, GetViewModelPosition stops working and won't even attempt to move the model. I don't really need information sent from one hook to another if that is what you meant. Sorry if I didn't clarify correctly.[/QUOTE] Show your code then. It definitely should be working.
-snip- I just figured it out, thank you for the help guys: Turns out viewmodel:GetAttachment(viewmodel:LookupAttachment("muzzle")) breaks Viewmodel movement.
Sorry, you need to Log In to post a reply to this thread.