roflmuffin / CounterStrikeSharp

CounterStrikeSharp allows you to write server plugins in C# for Counter-Strike 2/Source2/CS2
https://docs.cssharp.dev
Other
741 stars 111 forks source link

Client not predicting value of AnimGraphUpdatedEnabled of a CBaseViewModel's anim graph #409

Open isaac-goldberg opened 4 months ago

isaac-goldberg commented 4 months ago

I'm trying to pause or disable player view model animations. I need it to be perfectly still, because I'm taking a bunch of screenshots of the view model and need the position of their arms/gloves/weapon to be exactly the same across all images. I have the player's CBaseViewModel, and simply setting the AnimGraphUpdatedEnabled to false on the server does prevent the view model from playing more animations. However, the view model keeps sort of shaking, quickly moving back and forth ever so slightly forever.

I assume that this is because the client is still trying to play more animations, like the idling animation, and has enough time to move ever so slightly before the server communicates back that animation is disabled and stops the view model from moving, and then it keeps repeating this cycle. I tried using SetStateChanged to transmit this to the client, and my implementation seems correct (I confirmed that m_bAnimGraphUpdateEnabled is network-enabled) but it didn't solve the issue.

This was my code:

Server.NextFrame(() =>
{
    viewModel.AnimGraphUpdateEnabled = false; // viewModel is a CBaseViewModel
    Utilities.SetStateChanged(viewModel, "CBaseAnimGraph", "m_bAnimGraphUpdateEnabled");
});

And here's a video of the issue I'm talking about (look closely at the left hand glove or the back of the AK)

Any ideas? Not sure if there's a problem with my implementation, a bug with CSS, or it's just a CS2 problem. Or, if you know a different way to disable/pause view model animations, that would be a perfect alternate solution too. Thanks in advance.