#its not getting despawned for me right

1 messages · Page 1 of 1 (latest)

hollow zinc
#

Post your code here and we can take a look at it

small flax
#
private void KnifeSpawnServerRpc()
{
    spawnedknifeTransform = Instantiate(spawnedknifeprefab);
    spawnedknifeTransform.GetComponent<NetworkObject>().Spawn(true);
}```
#

this is knife spawn code which is working well and its attached to player prefab and its spawning once as it should even if multiple player joins the game

#

but the issue arises with despawn code, when the game host calls it then it gets despawned but when any of the clients call it then it wont get despawned, heres the code below

#
public void KnifeDespawnServerRpc()
{
    spawnedknifeTransform.GetComponent<NetworkObject>().Despawn(true);
}```
#

the issue it that clients are unable to despawn the knife

small flax
#

@hollow zinc

hollow zinc
#

Are you getting errors on the host? If this code is on the player object then you shouldn't have to worry about ownership.

small flax
#

no its despawning as it should on host

#

but its not despawning if the client player tries to despawn

#

@hollow zinc

hollow zinc
#

I mean when the client calls the RPC, are you seeing any errors on the host

hollow zinc
#

Is the RPC getting called at all on the client?

small flax
#

im not sure