#archived-networking
1 messages · Page 109 of 1
yes
but it can be anything aslong as you change it spawnpoints = GetComponentsInChildren<what ever component>();
nothing
i just made another script for spawn manager cause it seemed easier but what do i change about the instantiate thing
the: ```
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using UnityEngine.SceneManagement;
namespace a.parkour.fps
{
public class Manager : MonoBehaviourPunCallbacks
{
public string player_prefab;
public Transform spawn_point;
private void Start()
{
Spawn();
}
public void Spawn()
{
PhotonNetwork.Instantiate(player_prefab, spawn_point.position, spawn_point.rotation);
}
public void DisconnectPlayer()
{
StartCoroutine(DisconnectAndLoad());
}
IEnumerator DisconnectAndLoad()
{
PhotonNetwork.Disconnect();
while (PhotonNetwork.IsConnected)
yield return null;
SceneManager.LoadScene(0);
}
}
}
so i remove thepublic Transform spawn_point; i assume but what do i change in the public void Spawn() { PhotonNetwork.Instantiate(player_prefab, spawn_point.position, spawn_point.rotation); }
Make a public Transform[] spawnPoints
that is already in the spawn manager script tho
i am just wondering what i put in the spawn function
Then pick a random spawnpoint like
int randomIndex = Random.Range(0, spawnPoins.Length);
Vector3 spawnPoint = spawPoints[randomIndex].position;
Not sure if I understand your question, but this does select a random Vector3 which you can use to instantiate an object
have this already return spawnpoints[Random.Range(0, spawnpoints.Length)].transform;
Alright then just call that method from within that spawn function
that picks a random spawn but i want to know how to instantiate there
Transform spawn_point = GetRandomSpawnPoint(); //Assuming you have a function like this
PhotonNetwork.Instantiate(player_prefab, spawn_point.position, spawn_point.rotation);
can somebody help me with this error. i can join a room and switch to another scene. When i leave the scene and go back to the main menu i get this error : PhotonView ID duplicate found: 999. New: View 999 on RoomManager (scene) old: View 999 on RoomManager (scene). Maybe one wasn't destroyed on scene load?! Check for 'DontDestroyOnLoad'. Destroying old entry, adding new.
i also cant join another room and switch to the game scene again after leaving one single game. i can after i restart the whole game though.
i also get this error at the exact same time
InvalidOperationException: Duplicate key 999
Hey guys. I am using Photon Transform View to sync players spine rotation but it is not syncing. I have added a transform view to its head and that is syncing tho. This is a mixamo character btw. Any help would be appreciated 🙂
You sure you aren't just overriding the rotation? I assume position does work
I would just temporarily throw in logs or breakpoints to confirm what is happening in the transform view component
I am using they transform view I have stopped the other client from using or changing my rotation I am very confused to why this would be happening
Yea this is not happening on other objects tho so that is why it confuses me 🤨
Is it happening though, did you check?
I am not near my computer
I will check now
No it doesn't work 😦
Do you think an animation could be overriding it
So the component definitely is syncing? Yea animation could override it
Ok i will check for that
No the animations aren't overriding i disabled the components
This is not a good idea by any means but should i try Rpc's?
It shouldn't make a difference if you confirmed that the transform view component is doing what it's supposed to
I yes but it is not syncing
How did you confirm that?
Because on the breakpoint it is not registering
Does the breakpoint trigger anywhere else in the script? Just making sure that the debugger is properly attached
Yeah it triggers on the character moving
Just not the spine moving
Idk why
I think I might synchronise myself
Tbh
Oh the transform view is nested?
Yes
Can't recall if there were any gotchas with that, but I think that should be fine with PUN.
Did you check if the other client is sending the rotation?
No no clients can send the slime royation
Sorry for the spelling mistakes typing on a phone is annoying
I meant if the owner of the object is writing the rotation as expected
Yes I put a breakpoint it doesn’t write tho
Yea then obviously nobody can receive it
I would just debug the component up the chain, it's using the same API as you should be using
Ok
Are you using the normal or classic transform view?
Normal
Debug the conditions
i did try classic btw tho
If OnPhotonSerializeView is not being called, check if the PhotonView is finding the component. The finding method seems to be the first one if you look for references to the IPunObservable
Yeah it does
So at what point does it fail?
does anyone know how to make random map change after like 5 mins with a timer at the top of the screen? here is my manager script ```
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using UnityEngine.SceneManagement;
namespace a.parkour.fps
{
public class Manager : MonoBehaviourPunCallbacks
{
public string player_prefab;
private void Start()
{
Spawn();
}
public void Spawn()
{
Transform spawnpoint = SpawnManager.Instance.GetSpawnpoint();
PhotonNetwork.Instantiate(player_prefab, spawnpoint.position, spawnpoint.rotation);
}
public void DisconnectPlayer()
{
StartCoroutine(DisconnectAndLoad());
}
IEnumerator DisconnectAndLoad()
{
PhotonNetwork.Disconnect();
while (PhotonNetwork.IsConnected)
yield return null;
SceneManager.LoadScene(0);
}
}
}```
May I ask, is it hard to migrate from photon pun to photon server? Does the syntax differ too much?
I have problem in photon when masterclient goes to background everything pauses
Hey. I am making a game with roles. I have 3 roles, Innocent,Detective and Murderer so far. How can I assign the roles individualy to all players? ( I am using Photon Unity Networking btw)
no one will write your whole script for you, they will only give you general advice just like welsh cow did lol
i did it this way first it will find random object with tag "Player" and it will assign Murder role to it then it will repeat same thing but with Detective and players who left are Innocents (Im not that good at photon so i dont know if this is best way)
Hi, Im using Photon Pun 2 for my networking and can anybody help with making a level voting system
should i use Pun or Mirror for player hosted servers
Mirror
alright, thanks!
Does anyone know of any public custom wheel collider scripts that can be used with prediction?
the default physx ones won't cut it. If anyone can share a script, that would be amazing.
Can I use both Photon PUN, Voice and Chat in one project? Or how would I "stack" Photon's types? Thanks
Yes
Do I have to create 3 projects in the dashboard for this to work? Like, 1 PUN, 1 CHAT and 1 VOICE?
Nah
You just import it for each one
so like import Chat Pun and Voice
oh wait now i get what u mean
basically import everything and create 3 projects in the dashboard and create a project for Pun Chat and Voice. Then go to your photon server settings and import those app id's
Great, thank you!
Can you make the player host locally with Photon or should I use Mirror for that? Thanks!
has anyone used unity remote config?
I'm getting a response of ConfigOrigin.Remote even if my internet is off and the cached version is being used
it allows player to modify the remoteConfig json and turn off their internet to bypass the servers overwriting their changes
you can use both
I think that is what Photon does
In Pun Players host locally
Oh I thought Photon provided a server
that's why they allow certain amount of concurrent players, well that's what I thought not sure that's the case
but in Fusion the new project in developement they allow Client Host Server Host and all that you need
so I shouldn't create a project as 'PUN'? Should I choose another one?
Sorry if these are dumb questions I'm just getting started with multiplayer
I have problem in photon when masterclient goes to background everything pauses
Not literary everything but wverything that masterclient controls
Background?
Hey, I want a networking system that works without a host. So the game is hosted by the server. But I don’t won’t to run the server on my own pc. Does anyone know what the right solution is for me?
Photon Fusion 🙂
i would like it a bit cheaper xd
You can use most networking solutions and host your servers on the cloud. There are services around like Playfab or AWS Gamelift which have been made for that or you can buy a VPS and do it yourself.
this method i tried it didnt worked
Then I'm not sure I understand what your problem is
my problem is when master client goes to background that everything master client controls will pause
i need some way to swtich master client when he is in background
Hey guys, I'm creating a lobby with MLAPI. Should I use the switch scene locally in Unity to move from the menu to the lobby, and then use the synchronized MLAPI scene change to move from the lobby to the game once the players are ready?
Another question: with the lobby I don't need the player pref spawned at connection time, how do I spawn it manually?
I resolved this
How do I check if a connection to a server was successful with MLAPI? I can't find any callback in the client-side
Only the server knows of all the clients. If you want a client to know whenever another client connects, you need to make sure that the server informs them (RPC's etc)
No, I mean, I need to check if my client has successfully connected to the server
So if StartClient() worked and the server was online
Do you have a default player prefab? If that case you can always override the NetworkStart method in your script using a NetworkBehaviour
As a player prefab spawning wouldn't happen unless you've connected successfully
the NetworkManager.Singleton.OnClientConnectedCallback will work the same way. You can assign a method or function that will call whenever you've connected as the client
private void StartClient()
{
NetworkManager.Singleton.StartClient();
NetworkManager.Singleton.OnClientConnectedCallback += OnConnectedClient;
}
private void OnConnectedClient(ulong clientId)
{
print("Client: " + clientId + " connected.");
}```
This can be used after using StartServer() as well. The difference is that the OnConnectedClient will be called for each client connecting for the server.
Whilst when it's after starting a client as the above example, then it will only be called ONCE, which is when "this" client has connected
No, I just deactivated it. I need to spawn the player prefab when the game begins, after the lobby. And I need to check the successful connection to enter in the lobby scene...
I think the callback above should work then?
Though you need to spawn it on the server, so make sure you add the callback after you've started the server
Wait. OnConnectedClient works both for the server AND the client?
I thought I could use it only on server-side
Ok, it does. Thanks!
Can I send a list of a serializable class in my ClientRpc parameters?
Hello,
what is currently the best solution for FPS networking (Fast FPS, like Quake, CS, etc)
Of course, Server/Client architecture would be nice and no p2p.
Thanks in advance.
Fusion
Why isn't my ServerRPC not being executed at all? (in the host, that should be both the server and the client)
void Start()
{
InitializeCards(); //This gets executed
Debug.Log("???"); //This gets executed
if(IsClient)
{
if (IsServer)
Debug.Log("I'm also server"); //This gets executed
AddLobbyClientServerRpc(NetworkManager.LocalClientId, name); //This does NOT get executed, and that's the function that I'd like to execute
Debug.Log("I'm client"); //This gets executed too, since it's a host
}
else
Debug.Log("...");//This does not get executed, as expected
Debug.Log("!!!!");//This gets executed
}
[ServerRpc(RequireOwnership = false)]
public void AddLobbyClientServerRpc(ulong client, string name)
{
Debug.Log("Text"); //This does not get executed
//Things...
}
I have no clue at all, the computer executes everything above and under the function, but it seems it's not entering in it
Ok no RPCs at all are being executed
I am calling an RPC on a different script but i dont get error but it dosnt work here is script RPC on different script https://hastepaste.com/view/X5fQYPxKDc
wait no i do get an error
could anyone help pls
i have spent ages trying to fixgure it out
i dont know why it dosnt work i havnt been able to figure it out
???
it is not being called but why?
Is there a way to call RPCs in MLAPI in a network object that's not been spawned? I need to call rpcs from clients, but the player prefabs is still not spawned, it will need to be spawned later on...
No I don’t think that is possible
Wait what are you trying to send
it is giving me a error Cannot implicitly convert type 'Photon.Realtime.Player[]' to 'Player[]' pls help
Show me your code
ok lets do this diferently
k
you see on joined room
yea
i will write some code then explaon
k
public override void OnJoinedRoom()
{
MenuManager.Instance.OpenMenu("room");
roomNameText.text = PhotonNetwork.CurrentRoom.Name;
foreach (Transform child in playerListContent)
{
Destroy(child.gameObject);
}
foreach (Player player in PhotonNetwork.PlayerList)
{
Instantiate(PlayerListItemPrefab, playerListContent).GetComponent<PlayerListItem>().SetUp();
}
startGameButton.SetActive(PhotonNetwork.IsMasterClient);
}
basically instead we run a foreach loop through the players in the room
and we instantiate based on them
so i just cp in
yeah
k 1 sec
try it
it says the same thing
show me
oh there is a small problem
ok do this
at the top
using Player = Photon.Realtime.Player;
k ill try
did that work?
im getting this now
k
?
foreach(Photon.Realtime.Player player in PhotonNetwork.PlayerList)
k il try
make that the top line
got it
errors?
ye 1
yeah
nah put lower case
k
Photon.Realtime.player
still no
wait a sec
ahhh do this instead
{
}
and then inside where you have setup
just put player
so
SetUp(player);
k
it work?
and inside SetUp(player)
yeah at then end of the line
k
Instantiate(PlayerListItemPrefab, playerListContent).GetComponent<PlayerListItem>().SetUp(player);
its givingme the same error as at the start
well maybe change the name of that
k
you have to change the name outside and inside
so if the name was PlayerController
go inside and change it too
public class PlayerController : MonoBehaviour
im so sorry
2 seconds im gonna test it
k
it works tysm your a life saver 🙏
np
Basically the data of the players connected to update the lobby; the LobbyManager needs to update a list of data like player names, if the players are ready etc.
why cant you do it when it is instantiates?
I do this using a script, a lobbymanager, that sends the client data with his Start(), using a server rpc... But since I can't use the server rpc without spawning the object, this seems quite wrong
What do you mean? The script is in an object in the lobby, it doesn't get instantiated
no but you said that you are trynna send an rpc to a prefab that is not yet instantiates
why cant u wait for it to instantiate then send the rpc
like upon spawning the player prefab send the info
hum... I'm not doing that
nah wait
The prefab will be instantiated in game
yes
and you are trynna send info to that prefab?
No
oh it is gonna be in another scene?
I've got an UI with all the players informatrion
in the Lobby
A list of cards, representing the players
wait so you are gonna be in the lobby then load into the game and you want the prefabs to have those values?
or have the info
Well... More or less, yes, but the prefabs will not "get" the information from the lobby
the data will prbably be stored in another way
Wait
Yeah you can create a dontdestroyonload object
then take it to the game
as it will save the values
i didnt watch that i have never used MLAPI tbh
but since you are dealing with rpc's it shouldnt be hard
wait so these guys get instantiated?
like when a player fills a spot
Summarized is: to use and receive rpcs I need a spawned object in the network, and I haven't one, so I can't send and receive other player's data
Nope
Currently it just switches scene and can only press the isReady button
But I think I'm forced to have at least one network object per client
so they can use rpcs
wait Lazy
i understand that they have callbacks?
like on someone connected and disconnected
well with that
what you can do
is create a dontdestroyonload object in the lobby.
then create a string[] and save it .
as it is dont destroy on load it will transfer to the game
in which you can grab the valuews
But it works if I spawn the lobbymanager as a networkobject
If I don't spawn my LobbyManager the rpc's about the "upload" and "download" of the data will not be executed, so every card just results in an empty slot
hmmm
if I spawn the LobbyManager, the host effectively connects
so is the difference between yours and dapper's code that he does it all in one scene?
A lot, I basically am writing my own code lol, I also did my UI (based on his video, but still, I downloaded nothing)
His code is way too complex and uses his libraries
I used some of it to resolve some problems
Anyway I think I must use a player prefab to do this
ok
If someone has another easier/cleaner option, it would be appreciated
but thanks anyway for the help
np
brainstorming always help ❤️
Not sure how Boss room does it, but you could always look at their code
Oh or the other example projects. I'm pretty sure there is one that does exactly what you need
let me find it for you
This project includes lobbies with scene management
I'm gonna do something similar myself, but I haven't gotten around to it yet so I can't help you personally
I have problem in photon when masterclient goes to background everything pauses
I know you need some way to switch masterclient when he is in background but i dont know how to script it
@cloud nest Which part? Make sure run in background is enabled to avoid this problem where possible, but when it can't be, I would check if MonoBehaviour.OnApplicationPause is called. PhotonNetwork.SetMasterClient() for setting the masterclient.
Wait what do you mean in the background
can i call an RPC from a different script to the one that the RPC is on I am using photon and i cant figure out why this dosnt work to kill the player
it dosnt even call the RPC
public void Respawn()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
Time.timeScale = 1;
photonView.RPC("Die", RpcTarget.All);
}
i get this error when i click the respawn button
and it takes me to the photonView.RPC("Die", RpcTarget.All); of the respawn function
can anyone help?
the script with the button: https://hastepaste.com/view/eVWj
the script with the RPC: https://hastepaste.com/view/eFndTesv
what do i do?
Thanks!
soooo... I have some questions with this code. I'll try to ask just the hardest ones, to not flood this chat 😛
How does he spawns the Lobby menu control? It's not a player prefab, and he doesn't spawn the NetworkObject anywhere...? If I place a NetworkObject in my LobbyManager (same as his Lobby menu control) I have to manually spawn the NetworkObject.Spawn(), and this also spawns my lobby manager for everyone. He has only one spawned lobby control in the lobby scene, even with more clients...?
does your gameobject multipause have photonview component? Try maybe gameobject.photonView.RPC ...
ok but in the void setmasterclient what player i need to set?
Hi, can someone please help me?
Unity console writing this errors:
Assets\Scripts\TestConnected.cs(23,41): error CS0246: The type or namespace name 'DisconnectedCause' could not be found (are you missing a using directive or an assembly reference?)
Assets\Scripts\TestConnected.cs(17,26): error CS0115: 'TestConnected.OnConnectedToMaster()': no suitable method found to override
Your class must be derived from MonoBehaviourPunCallbacks
Does anyone know what this mean??
PUN is in development mode (development build). As the 'dev region' is not empty (asia) it overrides the found best region. See PhotonServerSettings
I am having problem with the mirror plugin where both server and client have identical script, but they are in two different game project. When I start the host, the client can join, but the client gets this error message:
I'm pretty sure he has each control in each scene?
So whenever people start the game (Main menu) the menu control is available in that scene. Whenever a client decides to connect they press a button and they're switched to the lobby scene
and inside the lobby scene is where the LobbyControl is. Spawning is not something you should do with the control, as there should only exist 1 per client
Spawning is only the concept of replicating a networkobject that exists on the server across all the clients, which is not what you want to do with the control I'd say
And what I assume you want to do is just creating an empty gameobject in the respective scene, and adding the control script to it as well as a networkobject
This example is for hosted lobbies too, hence the checks for "isHosting"
i got 1 error when importing pun
hello
UnityEditor.AssetDatabase:ImportAsset(String)```
i think its a weird one
So I'm not correctly understanding what he did there
When you join the lobby, he spawns both the playerprefab (it's hidden in the scene but you can see it in the hierarchy) and the lobbycontrol... The lobbycontrol has a networkobject, and can send RPCs
However, if I do the same with my lobbycontrol - that I called lobbymanager - the network object is not active, or spawned, and if I look at it in the hierarchy, with the game on play, there's a button to manually spawn it
Lobbycontrol in the invaders project has not this button, and it is automatically on, both for the client and the server
That's his lobby control
And that's mine, if I don't spawn it manually - and I can only do it in the host
I have not cloned the repo myself, so I can't really see. But it seems he has 2 prefabs, one being "NetworkManager" and one "Invaders Game Manager"
Maybe one of these prefabs does some of this work?
I'm... not sure? I'm looking through the Scene Transition Manager inside the NetworkManager, but it's pretty complicated, so many callbacks... However, if he calls a .Spawn() for the lobbycontrol to spawn it and use the rpcs, shouldn't the object be spawned to every client?
Yeah so the server is probably calling spawn once to replicate it, for the lobby control that is
Or, maybe, he uses a ClientRpc with the .Spawn() executed only by the client that connected and has not a lobbycontrol... Is that possible?
The menu control isn't
If the server is calling spawn he should do it for every client that connects, to activate his lobbycontrol
So, there should be one lobbycontrol per client
or maybe that's true
There should be one per client, yes
I tested it: when two connected players join the lobbycontrol is still one o.o
Because it is decided who is hosting in the awake method
Of the lobby control
Well there should be 1 lobby control on each client
There shouldn't be a lobby control for each client
That's what's happening, but I can't understand why: the .Spawn() method spawns the networkObject only in local?
I mean, not replicating it everywhere
Well say a client connects, then it has nothing
The server knows a client just connected, and will spawn the lobby manager
So each client will be assigned 1 lobby manager each
but the server will still have only 1, which is how it should be
Yeah what I'm not understanding is why it spawns the lobby only for the client
i mean how
if I use .Spawn() it spawns the object for everyone
I'll just clone the project myself lmao, I need to check the prefabs and the scene
To be fair the lobby control has no NetworkStart
So I don't think it's being spawned at all
and only has the networkobject to use RPC's
It is just assigned in the scene and stays there on both client / host
Not sure if that's a thing though, I haven't use networkobjects outside of prefabs
Yeah that seems to be the case
In the main menu it is decided who is host, by setting the static bool in the Lobby control. Then the scene is switched to the Lobby which Instantiates the gameobjects in that scene (LobbyControl) being one of them
the Awake() is therefore called and starts a host, or starts a client etc etc
If it's the host, it will start listening for connections, to where he adds himself to the list of connected clients and then add callbacks to be notified whenever new clients connects
if all the players are ready, the callbacks are removed from the manager etc and the scene is switched to the "in game"
And since the networkmanager will exists between scenes if I'm not wrong (it isn't destroyed), the same networkmanager behaviour is just carried between scenes
So why is it online? My networkobject must be spawned in order to work
That's a default in mlapi, i think
If you destroy it the connection stops
Well to be fair no host is started yet when the LobbyControl exist
Because the host itself is started within that script
so spawning anything prior to that isn't even possible
Wait, so.. if I start the host after the lobby the networkobject automatically gets spawned?
I think you're too hooked about the spawning of the lobby controls
what I understand is that they're not spawned at all
Because my object is not online
Well
That's spawned
And mine is not
Both screenshots are in the lobby
His networkobject is online and can send rpcs, mine is not and can't
and I can't find why my networkobject is not online if it's not spawned
Anyone could help me with this problem I'm running into? 😅 #archived-networking message
maybe this is true then
Wait.. Im going to try something
Nothing, it's not working
I really have no clue why my object has to be manually spawned and his doesn't 😦
it didnt but i added it and it still didnt work and got error
???
try referencing it in inspector by adding [SerializeField] PhotonView PV; in your class
then try to execute via PV.RPC(...)
still
i still get that error
the pause menu thing is not part of the player cause that gives me problems with the leave button
do you have to make joining an RPC?
I'm sorry that doesn't make sense? The way the code works is that as long as it can see the host on server discovery, it immediately joins (It's intranet based only, not internet base).
srry then i dont think i can help i looked at the error and saw RPC and thought you needed to make joining one i dont really know anything about the networking thing you use cause i use photon sorry
dosnt work
I don't know if you done correctly what I said, for me it should work (NRE should be gone)
so what is supposed to happen is when the player joins a game they can access the multiplayer pause menu (which is in that scene all ready and in no way connected to the player) and they can hit the respawn button and it kills them but it dosnt do that and gives me an error
PV.RPC("Die", RpcTarget.All);
[SerializeField] PhotonView PV;
Did you set your photonview in inspector?
I think so
Look at screenshot
if you are wondering why the multiplayer pause gameobject is not active it is because it gets turned on when player presses esc
script on the canvas (parent of multipause)
and i set the phootn view on it
now i am getting this error
I think i have to attack the multipause to the player prefab but then i cant use the leave function
yes
wait do i put the player prefab in there?
If you want to call RPC on some object - this object MUST HAVE photonview too and you must refer to that photonview and then execute rpc
So you must refer to object's called "Target" photonview
because there you implemented your rpc function
how do i do that tho cause i set the player prefab as the pphoton view but when i tried it got this
and it didnt work
how do i make it so it kills the player who presses the button
???
you must store somewhere a player gameobject which pressed the button
how
Learn some basics of programming then try to make a mp game please, I don't wanna explain here all c# stuff related
ok
So, I'm learning Mirror, and with this code if the client presses space, the host moves up, and if the host presses space the client moves up. The client also sees no changes at all. Can someone help me figure this out?
So I copied some code from a tutorial, and I still have the exact same problem, so I don't think it's something with that
Here's my network manager
And the network identity of the player prefab
i am making a third person shooter game using Photon PUN
how can i make players instantiate with a random playercontroller prefab from a list of diffrent playerController prefabs?
i want to do this because i dont want all players to look the same
Just do prefabs with different playermodels and in your network code when you instantiate player do a list/array with these prefab and then randomize it something like ```cs
[SerializeField]
private GameObject[] playerVariants;
public override void OnJoinedRoom()
{
GameObject spawnedPlayer = PhotonNetwork.Instantiate(playerVariants[Random.Range(0, playerVariants.lenght)], Vector3.zero, Quaternion.identity);
}
oh
thanks
also
suppose player1 got blue controller,
from another player's perspective , will player1 be blue or will it be any other prefab?
Yup. If I start the server/client in the lobby, with the lobbymanager already loaded in the scene, it gets spawned. Damn man, so much time lost for something not really intuitive...
Is there a way to get a console error in MLAPI due to a failure in executing RPCs? Now my object is spawned, everything should be fine, but it still refuses to execute all my RPCs, with the networkobject spawned and the connection active. No errors in the console, nothing...
Probably you're testing on localhost and the port is already used by another application ?
2 apps can't use the same port on the same address
i need some MLAPI help
I am programming a FPS game with MLAPI as multi player api. Instead of Raycast i am shooting instanced bullets tho they only seem to work on the owner.
What do I do to make it work on the client as well?
Hey. I want to make an item that if you type the player's name in an input field and press a button, the player dies. How can I do this? Thanks.
so kinda like the Death Note lol
guys I need help with making a huge decision.. my game is more than 95% done , like all i need to do at this point is to make better materials and edit some things in maps... but I also am thinking about moving from PUN to Fusion cause fusion is much better especially in the case of my game, yet at the same time I am having a rough start at it, I dont know why.. lots of people seem to be working with it with 0 problems... and i am not sure what to do anymore, stay using PUN or move to fusion ...
if someone has used both please give me your opinion
If you're 95% done, then whatever Fusion supposedly brings you cannot be that crucial, and if it's delaying you I personally don't see the point
Plus depending on project size, if you're 95% done, changing to Fusion from PUN could set you back a good while
you're right thank you
95% done is a tough decision
then whatever Fusion supposedly brings you cannot be that crucial
This is the interesting point indeed... If you say you are really that complete with PUN, then either:
- you do not need all the features fusion brings compared to PUN (it's miles different, fusion is closer to Bolt than to PUN)
- or maybe you are NOT 95% done...
I would release to the market what you got as a v1, then work on your v2: migration to Fusion + implement players feedback on the v1
So answer is yes to both 🙂 (I hate to pick choices)
But as Erick said, if you don't see much of a difference with Fusion, did you really need its features ?
ah I see. Good to know at least
I got an error when importing pun
UnityEditor.AssetDatabase:ImportAsset(String)```
what is that
I would guess it's some Unity issue
Odd question. What kind of netcode does Mirror use?
My friends are obsessed with rollback netcode, to the point where they bought Guilty Gear just to see how far they could push it. But I have no idea what Mirror uses
I can't seem to find anything online
Mirror uses client server just transferring changes from the objects to the clients
It does not qualify either as deterministic predict rollback (which is what people normally mean when they say rollback netcode) or as tick based state transfer (the basis for snapshot interpolation, client side prediction and lag comp)
If what you want is predict rollback like the type found in platform fighters or fighting games, off the shelf you have photon quantum. Other than that, you need to build yourself
Is this the correct way to do this? The player is supposed to rotate and reflect that change to everyone, while the camera (the player's child) is supposed to rotate client-side only, since each client only has their camera in the game
When I run it, as soon as I move my mouse on either client or server, it seems to make two copies of the NetworkManagerHUD but if I disconnect the client and rejoin it works perfectly
Got it working using a TargetRpc
FishNetworking just managed to send a rpc in 2 bytes. I am seriously looking forward to the official release.
Seems like the way scenes are managed are changing in MLAPI 0.2.0
Some changelogs if you're interested
So might be worth waiting for that
I'm using Mirror. How am I supposed to override functions on NetworkManager? If I make a script that inherits from it I get "Multiple NetworkManagers detected in scene"
Got it. I literally just deleted the main one
Hello guys. Am creating a Multiplayer game and I tried to apply a damage on the same script attached to the player but it keeps telling me DealDamage can't be found on photonview 1001
I will drop the script later
MLAPI, I have a client instantiating an object. I call a ServerRpc and instantiate the object and then .spawn(). But the problem is I need the player that spawned the object to know which object was spawned in his scene. How do I do this ???
how do I send a call to a clientId?
Hello guys, I'm using mlapi and while the docs explain how to send a clientrpc to a specific client, they don't explain how to do a "foreach" with the clients connected
How can I do that? I need to manually spawn a player prefab and give the ownership to the corresponding client
With mlapi?
Uhh, nevermind, playing with the code I found the dictionary "NetworkManager.ConnectedClients" 😄
@indigo thicket yeah, with MLAPI
I'm confused who is the owner of animator variables as well
If by call you mean data, or executing a function, then you must use a clientrpc with parameters
A ClientRpc can be invoked by the server to be executed on a client.
like that
and as a ClientRpcSendParams you set the clientid
and then it will only arrive at that single client?
or do I need to manually check the Params?
"The following code provides an example of using ClientRpcSendParameters, which will allow you to send a ClientRpc to a specific Client connection(s) whereas the default MLAPI's behavior is to broadcast to every single client."
it will arrive at that single client
Well you have to know the client id
and set it
yeah, I know how to get the clientId so that's okay 🤔
basically I have this code on my player
public class Player : NetworkBehaviour
private void Start()
{
playerInput = GetComponent<PlayerInput>();
playerInput.enabled = IsLocalPlayer;
}
public void OnAttack(InputAction.CallbackContext context)
{
if (context.performed)
{
DoDamage();
}
}
public void DoDamage()
{
Collider2D[] results = attackCollider.GetOverlappingColliders();
foreach (Collider2D col in results)
{
if (gameObject.GetComponent<Player>() != null)
{
NetworkObject networkObject = gameObject.GetComponent<NetworkObject>()
var clientId = networkObject.OwnerClientId;
ClientRpcParams clientRpcParams = new ClientRpcParams
{
Send = new ClientRpcSendParams
{
TargetClientIds = new ulong[]{clientId}
}
};
TakeDamageClientRPC(1, clientRpcParams);
}
}
}
[ClientRpc]
public void TakeDamageClientRPC(int damage, ClientRpcParams clientRpcParams = default))
{
Debug.Log("I got damaged!")
}
But I can only call "DoDamage()" on the server then?
Hey guys, I saw a few physics networking related questions above, this event today might be helpful for you since there will be a Q&A session with Photon team
@indigo thicket its not working 😢
Yes
Everything that has to be done on the network must be either called by the server (if you're the client you can call a ServerRcp) or done by the client on one of his objects
Doing damage is something that has to be done on the network
because the server and the other clients must know how many HP the enemy/other player has lost
So yea, you have to use a ServerRpc as a DoDamage function
If that was what you were tying to do, no need to do the client filtering that you were doing: the ServerRpc will be called once by the client, and will be executed only by the server, once
okay 🤔
so the problem is that my AttackCollider is not rotated on the server 🤔
working on it...
Guys! Do you know any way to get the line where the NetworkManager is returning an error?
I've got this problem so many times: I do something wrong with the code, like trying to use a clientId that doesn't exists, and the console correctly prints an error, but the error has no specific line of my code, but only MLAPI's code
Like this error: "KeyNotFoundException: The given key was not present in the dictionary."
I have no clue what is giving it, and since the console doesn't tell me which script is calling the line that is causing it, I can't fix it
@indigo thicket it works now.. I think :p thanks!
No problem 🙂
no, I don't have experience with photon 🤷
Usually better to ask a specific question, that way the conversation moves faster
Also allows people who don't know Photon, but have good Google Fu to have a crack
My Issue is that i want to Destroy a player if the health is 0 but it destroys it for 1 Player but for the others it doesn't work :/
@sour crystal there are plenty people here who are experienced with Photon, you should just describe the problem as clear as you can and possibly post some code that you think is the cause. Nobody will be able to pull an answer out of a hat without more background
Does Unity require a license per dedicated/virtual server instance? Playing around with ummorpg and just curious. /thanks 🙂
Hey guys. Do you think that the new networking solution in the 2021.1 version of unity can compete with the other ones like PUN and Mirror?
Nobody knows, but best to not wait for Unity to lend a helping hand in networking and just use something that already exists and has good adoption
The best is the one you make, but modifying mlapi the way you want it is also a really good option
Using MLAPI. I'm using .Spawn() for clients but I need each object spawned to call a method, how do I do this?
Call the method in their Start function maybe
Well it wont work that way. I have features I'm doing to the object while a player is holding it. When they build it then I need to activate the object so the features go away.
Wait I’m very confused
And using .Spawn() I cannot call a method on the clients to turn off the features
No my build objects have a method, ActivateBuildObject(). I call this when I build the object.
Yeah
.Spawn() puts the objects in the scene but I cannot call ActivateBuildObject() with .Spawn()
If there is not a way to do it then I'll compromise
Just curious if there was a way.
Very confusing lol
what is confusing?
Idk what do you mean you can’t call activate thingy with .spawn
Do you know what .Spawn() is?
Ok, its instantiating same object for clients, right? but the object has a script that I want to call a method
IDK how to call the method other than Start() function on script but I'd have to do a lot of work to change this up
Well
You can use events
Like subscribe to the event when you have spawned
And call the function
Here is another example of a problem I'm having. Maybe you can help.
Yeah
currentBuildObj = Instantiate(bs, buildPos, Quaternion.identity);
Yeah
for solo I set the currentBuildObj to instantiated Obj.
Yeah
But trying to do multiplayer now. and I cannot do this anymore
I do ServerRpc to instantiate on server, then .Spawn()
Yeah
So what is the problem in doing this in the rpc
Instantiating in the rpc
Idk
The player spawning the object needs to know which object he has spawned
Client spawns object. ServerRpc then .Spawn(), ok, I get this. But I need the client that spawned it to know which object they spawned.
I need each netObj.Spawn() to call a method. Any way to do this ? 😦
[ServerRpc]
public void InstantiateBuildObjServerRpc(Vector3 desiredPos, int objType)
{
NetworkObject netObj = Instantiate(gm.buildLoadObjects[objType], desiredPos, Quaternion.identity).GetComponent<NetworkObject>();
netObj.Spawn();
}
You can assign the objects with tags so do this
netObj.gameObject.tag = “netObj”;
Then when you wanna find them
GameObject[] = findgameobjectswithtag(“netObj “)
You can use an array
And findgameobjectsssssssd
With an s
Will find all of them
ok makes sense, thank you
Then you can to somin like this
🙂
I also noticed something but its prob bad programming. I noticed the Start function isn't called immediately after the object is Instantiated, so if I wanted to do something in the Start function I can set a bool just after I instantiate it. If this makes sense.
OnEnable does it immediately after instantiated?
Ye sure
I take hosts map seed and generate the same world for clients
So the dynamic objects and enemies are giving me an error cuz I just instantiate them on clients side, I have to use .Spawn() on server side for thise?
Yeah
I would assume so
Maybe
I have rarely used MLAPI lol
I can understand a bit tho
ok thank you. I have player equipment and custom appearance and login done so far.
awe ok
Nice
working on building and map seed generation
Ok thanks
its not an MMO, its more like Valheim
Ye
I’m interested in learning different solutions
I only know steam photon mirror and a bit of MLAPI
So just thinking
But thanks
I think MLAPI only lets me host 1 spot free. Until I add umm, forget what its called to store in the game lobbies
Np
is MLAPI beginner networking friendly?
Yes
Wdym 1 spot
You can host as many servers /hosts you want with mlapi
Just make sure change ip or port
oh @weak plinth ok. I will look into this! 🙂
Any good tutorials on this that also shows you how to config ports on the hosts router?
Check on unity webpage
You should be able to setup mlapi in less than 5 minutes
Ok so I have a role online game and I have a problem. The role assignment works but when u have any role in ur perspective all other players have the same role as you. How can I fix this?
// Update is called once per frame
void Update()
{
if (PhotonNetwork.playerList.Length == 6)
{
if (HasRole == 0f)
{
Players = GameObject.FindGameObjectsWithTag ("Player");
pv.RPC("AssignRole", PhotonTargets.AllBuffered);
}
}
}
[PunRPC]
void AssignRole()
{
HasRole = 1f;
Lobby.SetActive(false);
Bus.SetActive(false);
forest.SetActive(true);
for (int i = 0; i < Players.Length; i++)
{
int rnd = Random.Range(1, 15);
playerRole = Players[rnd];
if (rnd == 1)
{
BecomeMurderer();
}
if (rnd == 2)
{
BecomeSheriff();
}
if (rnd == 3)
{
BecomeDoctor();
}
if (rnd == 4)
{
BecomeDetective();
}
if (rnd >= 5 )
{
BecomeInnocent();
}
Role = rnd;
}
}
Hey guy, I'm trying to build a multiplayer WebGL game with photon. everything works well in the editor but I can't join room when I host the game or play it locally
thank you in advance
are you calling the OnJoinedRoom function to make it go to the game scene?
yes
other photon lines are working like for example I attached a photonNetworking.loadlevel method to a button and it worked but not anything in the OnJoinedRoom method
u have to make the buttons have a JoinRoom function (its a different function to whatever networking system u have)
are you saying I should make a button for creating/joining rooms? already done that and I have other method which is OnJoinedRoom() that will excute something after joining the room but it doesn't work
I'd say as many as your bandwidth can handle 😛
I'm currently working on a 2d battle royale shooter in MLAPI, and my goal is to squeeze in 64 players per game
we'll see how it pans out
@crude sleet We don't have job or collab posting on the discord server. There's a section on the forum.
Oh sorry!!
May I ask, so, I have two players on the same server, but (doesn't matter who joins first) the camera follows me on pc, only my actions
What is wrong in my code? I can post other code from file if this code is ok
public Transform followTransform;
void FixedUpdate()
{
if (IsLocalPlayer)
{
this.transform.position = new Vector3(followTransform.position.x, followTransform.position.y, this.transform.position.z);
}
}
what is followTransform set to?
thats really the only possible thing that could be wrong here
player prefab, and the player is spawned as a clone with the help of mlapi
okay maybe you need to explain a bit more about your setup
this is on the camera, and the camera is in the scene at the start?
the players are then spawned in whenever they join?
if the players arent spawned in at the start, then how is followTransform actually being set
the players spawn when they join, its a dedicated server preprealpha
I have main camera and player prefab has main camera child
ah
so there is no camera in the scene at the start, but each player spawns in with their own camera?
so there are like, tons of cameras in the scene then?
2 or 3, later up to 17
well there's your problem
cameras arent guaranteed to render to the screen in any particular order
unless you manually change their render order
you should rethink your camera spawning logic
but I've set the camera to do something only if its IsLocalPlayer..?
but you said its a child
yes
so it will already move with the players
you dont need to code anything
all cameras are already moving with the players
so you are just viewing the first camera in the randomly ordered list
which could be any one of them
what I was going to say though, is that instead of having the camera be a child, you should manually spawn in the camera in Start if you are the local player
like
private void Start()
{
if (IsLocalPlayer)
Instantiate(cameraPrefab);
}
wait, why camera prefab? I don't have it, only main camera and children...
I know you don't have it, you should make one
having 17 cameras in the scene is very not optimal
you should only have 1 camera in the scene unless you are specifically using more than 1 to do something
but I need one camera for each player?
that is not how it works
the scene hierarchy is not synced on the server
you can locally, as a client, spawn in a camera
and it will be your camera
all players will do this, so they will all have a camera, locally
the server does not need a camera since well, it's the server
and each client should not have other player's cameras
only your own
should I do something with the main camera? Keep it, trash?
but I need something for the menu?
Oh, is the menu not in a different scene?
I suppose you could keep it then, and just disable it and spawn in player camera locally when the game starts
but how do I disable a gameobject? I know how to do that with components only
gameObject.SetActive(false);
this is a long conversation so I will make a thread
Hello I was watching a networking tutorial and he made this script he did not get the error but i dont want to do anything wrong so i came here i have searched online but couldn't really find anything the script is:
if (PV.IsMine)
{
Hashtable hash = new Hashtable();
hash.Add("itemIndex", itemIndex);
PhotonNetwork.LocalPlayer.SetCustomProperties(hash);
}
and the error is:
namespace 'player' not found
the error occured at LocalPlayer
[Photon Pun] - Objects with PhotonView component must be instantiated with PhotonNetwork.Instantiate only ?
yes, if it has a PhotonView then the server sees that as a network entity
so you must use the photon instantiate to create it, not unity's Instantiate
What is IsLocalPlayer? Does it check if the file is attached to a player object that is controlled by someone locally or what?
Whether the object represents the locally running instance of the app on the local Computer you are sitting in front of
Okay! 🙂
May I ask, how do I reference clones from the prefab? Tags and names I think are not an option since there is more than 1 player(clone) name and more than 1 player(clone) with a tag
How do I make clients collide with .Spawn() objects using MLAPI? My clients are moving through the .Spawn() dynamic objects but my building fort objects are colliding with host and clients... The main difference is the dynamics have rigidbody dynamic with NetworkTransform.
May I ask, how to make one camera clone follow one player clone and other camera clone follow other player clone? Right now the code is a mess and everything is bad
Hey guys what is the best networking sullutions for to make?
When i press host i make a server on my own pc and other poeple can join a way that i dont need a server?
clients can't send commands
I'm spawning in player objects and then they can select a character
once they select one, they send a no authority command to the server that creates a player which then gets spawned, giving them authority
however, once the player is spawned, the rest of the script doesn't work anymore
public void CmdSelectCharacter(NetworkConnectionToClient conn = null)
{
MyNetworkManager.instance.CreatePlayer(selectedCharacter, conn);
Debug.Log("Ara");
/*characterCards.RemoveAt(remainingCharacters.IndexOf(character));
remainingCharacters.Remove(character);*/
DestroyAllCards();
}```
{
//Creates player prefab
GameObject playerObject = Instantiate(spawnPrefabs[0]);
NetworkServer.Spawn(playerObject, conn);
//Sets player name
CSteamID steamId = SteamUser.GetSteamID();
PlayerSteam playerSteam = playerObject.GetComponent<PlayerSteam>();
playerSteam.SetSteamId(steamId.m_SteamID);
//Sets player character
Transform playerCharacter = Instantiate(character.CharacterPrefab, playerObject.transform).transform;
playerCharacter.GetComponent<ChildNetworkIdentity>().parentNetId = playerObject.GetComponent<NetworkIdentity>();
playerCharacter.GetComponentInParent<PlayerData>().data.characterId = CharacterDatabase.instance.GetCharacterIndex(character);
NetworkServer.Spawn(playerCharacter.gameObject);
//Add player to world save
//Adds player to the list of players currently in the game
if (!gamePlayers.Contains(playerObject.transform))
gamePlayers.Add(playerObject.transform);
}```
this is the function that creates the player
also, I might have to specify this
I am using Mirror networking
Hi, I have a problem with 2 errors. Unity Console still writes:
*1st* ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <695d1cc93cca45069c528c15c9fdd749>:0)
UnityEngine.UIElements.VisualElement+Hierarchy.get_Item (System.Int32 key) (at <0ec220f696a74948a0877e75f89752cf>:0)
UnityEngine.UIElements.EventDispatchUtilities.PropagateToIMGUIContainer (UnityEngine.UIElements.VisualElement root, UnityEngine.UIElements.EventBase evt) (at <0ec220f696a74948a0877e75f89752cf>:0)
*2nd* Assets\Prefebs\MainMenu\UI\Rooms\RoomListingsMenu.cs(23,57): error CS1061: 'RoomListing' does not contain a definition for 'RoomInfo' and no accessible extension method 'RoomInfo' accepting a first argument of type 'RoomListing' could be found (are you missing a using directive or an assembly reference?)
and I don't know what to do with it. Would anyone help me? Here is the .cs file:
you should use NetworkServer.AddPlayerForConnection(conn, playerObject)instead of just NetworkServer.Spawn when spawning the actual player controller
I'm already spawning a player in
clients dont enter a ready state by default unless you use this function
I tried using ReplaceClientForConnection
but it still doesn't work for the clients
I have a script that sits on buttons that let you select the player
{
CharacterSelect.instance.SelectCharacter(character);
}```
{
selectedCharacter = character;
CmdSelectCharacter();
}
[Command(requiresAuthority = false)]
public void CmdSelectCharacter(NetworkConnectionToClient conn = null)
{
Debug.Log("Ara");
MyNetworkManager.instance.CreatePlayer(selectedCharacter, conn);
Debug.Log("Ara");
/*characterCards.RemoveAt(remainingCharacters.IndexOf(character));
remainingCharacters.Remove(character);*/
DestroyAllCards();
}```
and then for clients
only the createplayer function gets called
and nothing else
and they have authority over their own objects
you don't get an error?
but once I send a command
it disables the client
disconnects them
and giving an error
like
how can I do this
once you join the server
you get assigned an empty gameobject for the player
and then I want players to be able to select a character using some buttons
once that's done
destroy the cards
but it only works for the host
there are no scripts on the empty gameobject?
just network identity
because you cant send commands from anywhere but the player object
so if you are trying to send commands from UI, it wont work
you can, however, send custom network messages without using any commands, and that does not require a player object to exist
so you could perhaps send the server a networkmessage that holds the ID of the character they want to select, then it spawns them in with actual authority after the server receives the message
and again, I strongly recommend spawning in the player using AddPlayerForConnection https://mirror-networking.gitbook.io/docs/guides/gameobjects/custom-character-spawning
what about if the card calls a command that sits on the player object?
like
the character select sits on the player now
Hey guys is their a way to get multiplayer without a server but not local like you can play with everyone you want from everywhere
I think as long as the script that holds the commands is on the player object, it should work
it does not
if it's on the client
only the createplayer function will be called
and nothing else
does the script that calls the other script with the command have to be a networkbehaviour as well?
I dont think so, I think you are doing something else incorrectly
you are telling me that CreatePlayer is called, but from where?
if your cards are client-side, then yeah that makes sense
I see
I have inventories tho
they're classes that hold a list of items
if I wanna add to them
how do I do that
that kind of stuff is difficult to set up because it all has to be server side pretty much
so basically you need the server to have all the details, then client simply receive only what they need to render and display numbers for, etc... what I mean by this is, the server might have the actual item class stored in the server-side inventory, but then the player might try to equip an item from the inventory, so instead of accessing the inventory directly, it would just send the index it wants to equip to the server. Then, the server uses that index to access the server-side inventory, and sends back some primitive data type that represents the item the user wants to equip
for example, it might send back an enum or an integer ID of the item
that way the clients can use that ID to lookup whatever it needs to render the item, like perhaps spawning a prefab, or doing whatever
It gets complicated trying to do inventories this way, but there isnt really another option
TDLR: the server holds all the actual data, and the clients only receive the very minimum data they need to do the rendering / etc
since they arent doing any of the actual logic
but the inventories stay on the players
like
all the inventory data is saved locally
and players load that data once they join the server
kinda like terraria profiles
or characters
however
I want picking up and dropping to first go through the server and only then save locally
so then you could just send a command to the server that you want to pick up some item, the server could then delete the item from the world, and TargetRPC the player who tried to pick it up and have them locally add it to their inventories
that way you wont have weird overlap where two players pick up an item at the same time and it gives it to both of them or anything
since its bouncing off the server first
but like
I don't want players to be able to pick up however many items they please
or drop them
so
I wanna have the server
verify the data
which once I receive the commands
I can do
and then save it
so it'll still be handled by the server
it is impossible for the server to do any sort of verification if you have the inventories held locally
hence why you can just cheat in terraria no problem
if you wanted it to be secure and accurate, it would have to not be local at all
whether or not that matters for your game or not is up to you
you are already probably using the "client / server" hosting architecture anyway, meaning the host could always just cheat however they want
it is complicated, you need an actual database for your game that is held online
like MySQL or something (NoSQL?)
not sure what is really standard
but that involves being online the whole time
this would be something for some kind of MMO
then you have to deal with user logins, sessions, and all this other junk just to have the inventories be (mostly) non-cheatable
well
the game can be played offline as well
so
f
I just want the data to be verified before being saved
if they change it after
then
that's that I guess
@abstract copper
how can I make it so the host doesn't have server administration
like
they can do anything
while the clients can't
also
how can I make it so you can't edit other clients' scripts
cause, rn I'm just setting them to false on the client
so
uhh-
Is the reason why there are no basebuilding/rts mmo
because the server would have to process all the logic, which means high cpu costs, doing it client side would mean a vulnerability to cheating?
I mean, even Starcraft 2 and Planetary Annihilation start dropping either framerate or simulation speed in matches with a lot of bases / units, and those games only have 2-8 players typically
so yes, the performance costs would just be too high
and any MMOs need server-side logic, meaning you couldnt do it client side
Just how important is verifying input on the server? I've been dealing with input delay, but if I just take everything at face value it's non-existent
From a networking standpoint, my game is similar to Risk of Rain. No dedicated servers, just 4 Steam friends
If your game is player hosted then dont bother, you really only want to do input validation and client side prediction if your game is competitive with dedicated servers (csgo, valorant, overwatch etc)
Ok cool! That's great to hear, actually
Yeah, client authority is totally acceptable for co-op games
guys so im making a multiplayer using mlapi
and i have an arrow that shows where each your player is aiming at
oh wait
wrong png
Ah yes.
looks like a good day
An arrow.
the one on the left is the actual user
and i dont want the arrow on the right to be appearing
i just want the player to see where he is aiming
here is abit more clear explenation
i just want for each player to see their own arrows
not other player's arrows
do u guys get it?
please anyone?
do i just if(!isLocalPlayer) arrow.SetActive(false)? will that work?
i dont know anything about multiplayer but that sounds the most logical way
IT WORKS
Thank you! I think figuring out what i want to do and what is feasible and fun is going to be a fun project and learning experience haha
I have pun2 and using pun cloud, how do i convert it to player hosted servers, what is The most common way,
Any help me please?
Hello! I'm using MLAPI. I'm adding many items in my game, every item has its script with the override function "Use()" of his master class Item. Every item has a prefab, and must be spawned in the game. Since the "use" function calls some server RPCs, and most of the items are animated and thus need a networkanimator component, I'm forced to place every item prefab in the NetworkManager prefab list, right? Isn't there any other way of spawning it? I would spawn every item prefab in local, but then the item could not call the rpcs and/or use the networkanimator...
Placing hundreds of prefabs in the networkmanager seems pretty messy
(the items would be placed with all the prefabs of enemies, players etc.)
There isn't much documentation about it so I installed MLAPI and just looked through the NetworkManager code, and saw you could do this. I don't have an actual network setup so I can't really test, but this seems like it would work
So, you would just make a ScriptableObject with various lists / arrays of GameObjects, each list / array named after a specific thing. Perhaps weaponPrefabs, enemyPrefabs, etc
then you would iterate through all the lists / arrays, and add a new NetworkPrefab for each of those prefabs
That should solve the organization problem when it comes to adding all the prefabs
You would have to test if this works because—after looking into it further, it seems they do some hash validation of the prefabs in the NetworkManager... I am unsure if what I sent would be all you need to do, but maybe it is. I would try it and see
is there any work being done on QUIC support for unity for now, unity preview or opensource
I'm confused regarding the difference between "IsLocalPlayer" and "IsOwner", I would expect my local player to always be its own owner? But maybe this is not the case?
Local player is the object specific to the player but the player can be owner of anything.
Don't use LTS? Where do you see that?
No problem then?
If you are making a board game however you might be more interested in PUN. It has room functionality built in.
okay, that makes sense I guess 🤔
I'm getting these kind of warnings:
How do I destroy something on the server side without my clients nagging about it?
this happens when I join the server (with a client) AFTER an object has been destroyed on the server side
I'm not certain, I use a lesser known networking solution. I'm not familiar with troubleshooting others.
Okay. I'd advise using LTS but if some reason you absolutely cannot, good news, there are plenty others that work without LTS. Bad news, none of them are officially released yet.
Mirror recommends it, but it will probably work. Sometimes there are Unity bugs that affect Mirror.
I don't use Mirror. I'm on FishNet and quite happy with it.
Not recently, but yes. I'm currently playing with Mirage on non LTS, which is quite similar to Mirror.
Sorry, that was to Danny. Read it wrong.
Hard to say. I like Mirage due to it's much better architecture regarding singletons and statics
and better separation between features of the networking solution, in case I want to swap things out
I didn't say that it has better support, just that it has already done a lot of nice things to the Mirror codebase that I value 😛
PUN. They have free CCU and you do not have to deal with having a server. I know you said you are considering that for later but it sounds like PUN would be ideal for your requirements.
It does look like James has taken solid ownership of Mirage, so updates to code are frequent. Few others are contributing regularly as well.
Worth noting that running a server generally requires port forwarding. To avoid that issue, you would need a relay server.
I was going to suggest Fusion but I wasn't sure of it's current state. I was looking this very moment.
Photon Fusion
yeah lol
It would seem PUN is being phased out, so I agree, try Fusion.
https://www.photonengine.com/en-US/Fusion
Global cross platform multiplayer game backend as a service (SaaS, Cloud) for synchronous and asynchronous games and applications. SDKs are available for android, iOS, .NET., Mac OS, Unity 3D, Windows, Unreal Engine, HTML5 and others.
Also join the photon server
they will certainly help you with fusion
there are also constant updates
And they have recently added matchmaking
Oh dang the landing page is throwing shade at other networking solutions 😄
I have not used MLAPI yet but I am familiar with Mirror's pitfalls, they are very real.
Graphs on the page
A little bit down they are comparing benchmarks.
Sorry what do you mean by that
oh thats a bit weird