Need help with some concepts.

Options
Hey Guys. I am having trouble wrapping my head around how to do some concepts. I am also having trouble with RPCs How do they work?
So the first concept;
I want to make a Lobby that waits for a full lobby (6) and puts each player into a team. I understand I would need RPCs for this. When that is done, I want to spawn them all In at once.

I also don't know how to do a damage system I have the health all setup but how do I send an RPC to say this specific player has reduced health?

Comments

  • jeanfabre
    Options
    Hi,

    You can find information on RPC here:

    https://doc.photonengine.com/en/pun/current/tutorials/rpcsandraiseevent

    In your case, you don't need RPC. RPC only works when you are already within a Room, playing with others, When a player is in a lobby, it means it's not playing with anyone yet.

    What I would suggest is the following:

    A Player wants to form a team, so it joins a room it creates, no one is there yet, but now the room is created and so it becomes visible in the lobby. You can then either list all rooms to players in lobyy for them to pick, or randomly assing players to rooms, as new player joins the room, they are assigned to a team. you can either either in turn is you have two teams, or let the user choose which team to be in, this process goes on until all team are filled, in that case you start playing the game, by either loading a new scene or simply remove the related UI and start the game itself ( that was hidden and pauses in the bg).

    also, I would also make use of the utilityScript "PunTeams" which is specificylla made to help get up and running with teams. I would duplicate this script to avoid clashes if you edit it ( like the Team enum)

    Damage and health management is not difficult. The latest version of PUN on the Asset store has a new demo called PunBasics-Tutorial, and in there a script called "PlayerManager". Study how the health was implemented, you can take it as is really, and simply affect your heath in a different way. Check out all places in the script where the "health" variable is used.


    Bye,

    Jean
  • jeanfabre
    Options
    Hi,

    Also, you should check the DemoPickup available in the PUN Package, it implements this PunTeams Utility Script.

    Bye,

    Jean
  • Buby
    Options
    Sorry, I used the wrong wording by Lobby I mean a waiting room, the players are already in the room I am just going to instantiate them once the room is full
  • jeanfabre
    Options
    hi,

    Yeah exactly.

    Bye,

    Jean
  • Buby
    Options
    I dont think you get what I am saying. I am asking how to do it.
  • jeanfabre
    Options
    Hi,

    ok, so if I understand well you want to know how to join a room an only instantiate players when the room is full.

    1: join the room
    2: using the OnPhotonPlayerConnected() callback you can be aware of when player join rooms, you can inside that callback check PhotonNetwork.room.playerCount and PhotonNetwork.room.maxPlayers to find out when the room is full
    3: if it's full, you create the instance of the player.

    If that's not the question you where asking, can you rephrase? and I'll try to answer it :)

    Also, be aware that you can instantiate something that is not what the user is going to play with, but it could be just an item in a list, or a gameobject that hosts data that you can then feed from to output data in a list, for your teams for example. Or when the user is changing name or color or peoprties while waiting for other people to join.

    so here, you have a large set of possibilities, don't lock yourself with just one prefab representing the player. you coudl have two, one to deal with meta data ( team, name, etc) and one for the 3d character representing it. Or a combination of both and inside it enable and disable components or mesh to show hide based on the context.

    Bye,

    Jean
  • Buby
    Options
    Great, Thanks!