Player re-spawn when player fall

Options
GFutur1919
edited February 2023 in Fusion

Hi, We are using Unity & Fusion for our project. We are using AutoHostOrClient mode.

Players Join the lobby and then search through the session list in the OnSessionListUpdated callback.So we need to know some data about the player(like player avatar prefab) before their Player instance (which inherits from NetworkBehaviour) is instantiated after joining a session.

We have a game where user can select their avatar, join a session with other players where everyone will be able to see each others Avatars.

What we're struggling right now is, when we use to re-spawn player after death or fall, on host side it re-spawn correctly but on client side it not works.

Does anyone have any Ideas or alternate solution around it?

Comments

  • Ninety
    Options

    Client-side changes to network transforms will be overridden by the host and therefore cancelled out. Where is ReSpawnPlayerOnFall called from?

  • @Ninety , thank you for response, This script is attach to plane and it has collider to detect trigger,

    Player is teleport to destination position but in next frame it back to previous position, we use network rigidbody in player.

  • Ninety
    Options

    Yeah, so, you're calling that method if the client has input authority over the character, but their position will be "fixed" (overridden) by the host in the next frame. That's why modifying position on the client side won't work. Try making ReSpawnPlayerOnFall an RPC, with targets sent to server/host only.

  • @Ninety Thank you for help, some how RPC call to set position not works every times, I have now try to destroy player prefab and respawn it, it looks like work but after spawn 2-3 time in single session it stop updates in client side(prefab spawn but not visible).

  • @Ninety , thank you for help, I am able to respawn now, Just destroy previous prefab and respawn new prefab using RPC call.