Netcode and statemachine

Hi, i have a question about netcode course, it is working with the statemachine you did in the third person course ?
Can we track each state easyli ?

It does work if you make it work.

I did this recently (it’s not complete, yet) and this is what I changed (so far): The base StateMachine has to inherit from NetworkBehaviour, and then the Update ignores any calls that is not for the owner

protected virtual void Update()
{
    if (!IsOwner) return;
    currentState?.Tick(Time.deltaTime);
}

In the PlayerStateMachine I moved everything in Start() to OnNetworkSpawn() with another gate

public override void OnNetworkSpawn()
{
    if (!IsOwner) return;
   // Do the start stuff
}

The rest is pretty much the same and works fine for now.

Syncing the transform is done using the NetworkTransform (or ClientNetworkTransform), but the animations was a headache. There’s a bunch of stuff if you google it, but you either have to use the NetworkAnimator (or a custom ClientNetworkAnimator) or Server/ClientRpc the stuff up and down the network. The default NetworkAnimator` did not work for me (I don’t know why) so I went with the custom version and I am Server/ClientRpc-ing values around. I’m not 100% happy with this, yet.

Hi Guys,

First of all thanks to @bixarrio for answering this question as our tagging system failed and it did not show up on our daily searches.

Could you let me know if this solved your question and which course/lecture this is referring to so i can correctly update it so it is in the correct place.

Thanks in advance!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms