#npc synchronization

1 messages · Page 1 of 1 (latest)

flat scroll
#

This should be a viable workflow for your shoving synchronization:

  • Client pushes an NPC
  • Client determines where NPC will be shoved and what "time flag" the shove will be completed at by using GetServerTimeNow() + shoveDuration, whatever that happens to be
  • Client locally sets attributes on the shoved NPC so that the player client has instantaneous feedback
  • Client sends time flag and "where NPC will be shoved" to server, allowing it to set attributes that all clients can see.
  • All clients (including the sending client) use attribute changes in order to initiate the active shoving state

conditions to consider:

  • exploiters can shove npcs into oblivion
  • clients that receive the timeFlag update should not apply the tween state if the delta for the shoving animation is greater than shoveDuration
#

from mop in general

#

just to keep a note of this

#

this would be my workflow

each client spawns a local npc (like in my npc video)
when a player close to me plays the attack animation i detect if they hit my local npc
if they do i push back my local npc
``` - suphi
flat scroll
#

"Client pushes NPC" I take it thats when the player gets hit and the server sends the fireclient to the networkowner

"Client determines where NPC will be shoved and what "time flag" the shove will be completed at by using GetServerTimeNow() + shoveDuration, whatever that happens to be" - the time would be time = GetServerTimeNow()+Tween length

"Client locally sets attributes on the shoved NPC so that the player client has instantaneous feedback" - sets the time and position attributes

"Client sends time flag and "where NPC will be shoved" to server, allowing it to set attributes that all clients can see." the attributes get replicated from client to serveR?

All clients (including the sending client) use attribute changes in order to initiate the active shoving state-- attribute changed event? not sure about how to get them to do it at about the same time?

sharp crest
#

to elaborate on this:
"clients that receive the timeFlag update should not apply the tween state if the delta for the shoving animation is greater than shoveDuration"
a client in this situation should either "snap" to the shoved position, or they should ignore the call entirely so they can be rubberbanded to their correct replicated location. Depending on whether you use an approach like Suphi's where NPCs are just attributes on the server side, or if you do it like where the server actually has full control over the NPCs character model, it will be slightly different implementation, but the general concept is the same

flat scroll
#

i think im just going to have server npcs

#

i feel like theres too much overhead on completely client sided npcs at the moment

sharp crest
#

So what I mean by that is

#

The AttributeChanged event

#

that will probably fire differently on all clients slightly

#

but that's why we use the time flag that is synchronized

#

we can use the delta from that to force all clients to kinda be in sync

flat scroll
#

oops i should of seperated my notes so that ik what ur replying to lmao

#

attributes replicate from client to server right?

sharp crest
#

Nope, you'll have to use a RemoteEvent and you'll also want to sanity check the shove. This is very simple though

#

You just need to magnitude check whatever the server sees as the NPCs position versus where the client is trying to shove them

#

plus might want to make sure the client is close enough to shove to begin with

flat scroll
#

plus i think this way that you have suggested may work better in this current usecase as I said pvp is the main aspect I might have some form of pve not entirely sure yet

#

over making the npcs completely client sided

#

and stuff

#

shoveOrigin is the original position of the player/npc before they got hit @sharp crest ?

sharp crest
#

You can do either, but I think it makes more sense to set a shove destination, so that even if a client has a discrepency on where they've got the NPC, it has a consistent "end goal"

flat scroll
#

ok

#

i just set the attributes manually

#

on the npcs

#

for now

#

should i add these to players too

#

with a character script

arctic sphinx
#

client sanity checks?

sharp crest
arctic sphinx
#

i know, pres's idea on doing npc synchronization sounded like something along the lines of "client sanity checks" 🤷‍♂️

sharp crest
#

Oh I get what you mean