#Best approach for MMO enemies

8 messages · Page 1 of 1 (latest)

opal marsh
#

Hi everyone, I'm making an MMO using mirror and need som tips on how to make the enemies. Whats the best way to handle a state machine? What should be server/client specified and so on.

So far I've gone with a state machine that has a separate state for server and client. Server handles movement, dealing damage and such, and client handles animation, player detection, and right now it handles state switching (I'm not sure if this is the best way). Right now the enemies function the correct way only for the host, clients can't damage correctly and have a whole bunch of other bugs.

Whats the best way to sync movement to clients? I tried using network transform but I can't get it to work properly.

If anyone have any code examples or tutorials for this it would be extremely appreciated, since I find it a little hard to find without having to spend a lot of money in the asset store on stuff I don't even know if it's that useful for what I'm developing.

desert lodge
#

is state a syncvar? can make state a syncvar so client and server run the same code based on state this helps for animations and other things, detection should be done server, almost everything with enemy can be server side,

#

move the enemy only on server though and on networktransform untick clientauthority

opal marsh
#

I have a enum syncvar that keeps track of state, and change both server and client-state in hook. My detection is done by client and updated on server via command, it seems to work ok, but I might move it to server. My movement is done on server but it doesn't sync properly, I use a combination of character controller to move and navMeshAgent to check if locations are viable.

This works great in single player but ive noticed that sometimes the navAgent and controller positions doesnt sync up, witch causes all kinds of problems.

opal marsh
#

Could it be that my transform is synced but not the navMeshAgent? Is so, is there any good way to sync the agent?

#

Heres an image of my issue with the Agent

dreamy garnet
#

Depending on how your hierarchy is setup, it looks like the NavAgent is higher than the capsule/rigidbody? I usually put my Nav agents as children of the main collider

opal marsh
#

They are both on the parent object, the same object as the network identity. I'll try and put the agent as child to see if it makes any difference.