#You ll probably have to show more like
1 messages · Page 1 of 1 (latest)
i am moving it with its navmeshagent
using setdestination
` [ServerRpc]
private void ShootInServerRPC(ulong zombieShot,int damage,int ZombieColliderIndex,Vector3 directionOfShot)
{
GunShot.Play();
ShootPointFlames.Play();NetworkObject gos; gos = GetNetworkObject(zombieShot); gos.GetComponentInParent<Zombie>().TakeDamage(damage); gos.GetComponent<AnimOFFANDRBOFF>().Colliders[ZombieColliderIndex].attachedRigidbody.AddForce(directionOfShot * -30f, ForceMode.Impulse); }`
i call this on shot
with this method
ShootInServerRPC(ZombieShot, Damage,index,Direction);
and that goes there at zombie script
`public void TakeDamage(int damage)
{
health.Value -= damage;
if (health.Value <= 0)
{
DeathClientRPC();
}
}[ClientRpc] private void DeathClientRPC() { ZombiePassiveGrowl.enabled = false; gameObject.GetComponent<AnimOFFANDRBOFF>().TurnOffClientRPC(); //PSCScript.ZombiesSpawned.Remove(gameObject); //PSCScript.ZombieScripts.Remove(this); }`
and it ends here at AnimOFFANDRBOFF script
[ClientRpc] public void TurnOffClientRPC() { agent.enabled = false; for (int i = 0; i < RBs.Length; i++) { RBs[i].isKinematic = false; RBs[i].interpolation = RigidbodyInterpolation.Interpolate; } ThisAnimator.enabled = false; Invoke("DestroyEnemyClientRPC", CorpseDissapearTime); gameObject.GetComponent<Zombie>().enabled = false; } [ClientRpc] private void DestroyEnemyClientRPC() { NetworkObject.Despawn(); }
are you moving the agent on the client side? Seems like thats the case, and would cause your issues of 1 client calculating it differently
yes actually, but i actually managed to fix the issue with adding network transform to each rigidbody/collider of the npc
it doesnt teleport now
yea thats fine, except you'll really want to remove the logic from the clients so they arent calculating all the navmesh stuff
is there a reason for it? just to keep in mind if i see something going wrong
also since my NPC has 11 colliders / rigidbodies, does that mean it sens alot more info for all of them and increasing delay alot?
since they now have network transform on each gameobject of their own
your server/host owns all the network objects by default (excluding spawned players), your network transform wont ever allow a client to update its location. A client that cant update its location shouldnt need to calculate the agent stuff
well 11 of them to be correft
its a client network transform
well im unsure of your exact setup, its something you'll have to fiddle around with but you might not want 11 for one npc. You likely dont need this many rigidbodies and colliders on that npc anyways
oops i saw the video its a human, let me reword
no its a zombiee D:
for that npc, if it has all those colliders/rigidbodies yet is driven by animation, you might just be fine getting away with syncing the parent (i assume the hips) and then the animation only. Once it turns into a ragdoll just let people calculate it differently, because syncing that for many npcs is too much
you're destroying it anyways, and i notice in a lot of games they do the same thing. Syncing the ragdoll isnt really needed
well how to do it then if i remove those network transform it will be teleporting again
and thats even worse
if i keep them, it will haunt the delay i assume
and thats also bad
i believe its only teleporting because every client is trying to calculate where it should go
ok then il make server calculate and remove those transforms and see where we at
also that means it must have network transform on the hips and not client network transform, right?
yea, but your client network transform probably wasnt doing anything since the server wouldve owned it by default
anything different from a regular network transform*
ok im trying rn give me sec
im having difficulties
so basically i set that logic only for host
but now client sees only that he is staying in 1 spot playing animation
i maybe should have put network transform on the prefab itself also, im giving it a try rn
its actually working thank you, but they are a bit floaty
they spawn a bit high off ground and die there also
and their ragdoll is not ragdolling
i mean it kinda is but since its floating its not doing much