Anyone know, or have some ideas, how to have a GameObject in Unity3D Multiplayer (UNT) that is accessible for two player. What i want to do is to have an object that can be dragged from both players.
I have been looking at tutorials and read documentation but have not yet figured out how to solve this.
I used a simple workaround, I made three GOs (one that is being moved (main one), and two GOs that just receive informations from two players). When one player drags main GO on their screen their GO sends info to corresponding GO on other screen, it receives information and moves the main GO, same thing happens with another player. (I did this in Photon)
Most of the multiplayer engines don't support two way communication, so you have to create two one way communications to simulate one two way communication.
Related
I am a beginner gamedev and trying to figure out how to go about implementing my game's inventory management system. I am developing a third person RPG, with heavy emphasis on inventory and crafting, and so it needs to be done right.
I essentially have a tablet device the player will be able to use to access statistics about themselves and should also be their method of ascertaining crafting recipe. An example scenario is as follows: player obtains three recipe items, Apple, Leaf, and Ash. They want to craft a healing poultice in the field. They remove their backpack, which serves as both inventory and a less powerful crafting station, and the camera moves to focus on the backpack as if it were an inventory screen, allowing the player to arrange their ingredients as necessary and then craft.
My problem is I haven't figured out how to manage the control switch. Ideally the player shouldn't be able to walk around and do normal traversal while crafting. Indeed having WASD usable as menu manipulation controls would be preferable. The game is of the type that realtime usage of inventory is part of the experience, so I dont want a static pause screen. What avenue do I need to pursue in my research for this?
I've looked into Cinemachine and state switching/statemachines but I'm still fairly puzzled by that whole affair. I can switch to a state so far, but only sometimes get out of it. I'm away from my computer at the moment so I don't have an example but this concept has been nagging me for hours.
Let's say I have an open world game that supports multiple players.
The game stores their positioning by X and Y in this world.
Also, whoever is playing the game can see a canvas of 11x11, where his player-self is represented on this screen, always centered.
The game world has 1000x1000 squares to walk using keys.
What I know is that:
I could emit events whenever a player walks,
check this event data at the server-side (to see if it is possible and the speed is correct/anti-cheating measures),
update the game state which contains all players and positioning,
re-emit this state from the server so every client would be able to render properly this new player.
The problem is, should I really update someone who isn't even being seen?
When everyone is walking around, moving items, earning levels, etc - those events are being emitted from the client, and that's okay, but thinking about the server-side, it will re-emit that for each update state, and, maybe that will be overloaded?
Also, sending the whole game state, even if it isn't being rendered, opens so many breaches to cheating that this made me think that there is another option.
I'm a beginner at Networking and Game Development, and that is being hard to get into my mind - so I decided to try and put it into a question. This way, maybe with someone reading what I'm thinking about, I might get some clarification. Perhaps I'm just thinking about it the wrong way.
Q: should I really update someone who isn't even being seen?
There is no need.
The normal way MMORPG games do in the server side is to cyclely process network packages and some other calculations like the connection of players like skill cast or something else.
The central of a server may look like below
void run()
{
while (true)
{
processNetwork();
processSkills();
processMoves();
...
}
}
The loop will run several times a second, like 20 frames a second is enough cause players can not feel the little frame, they think they move/play smoothly but the trueth is not.
For your question, player only need to see some little area, when he moves, the server will braodcast his postion to others in the area and the players in his area in the next frame.
And that is just the simpliest model, actual model will be more complicated and we will detach different functions of the game to different server, sucn as chat server, battle server, auction server and others.
I am working on simple multiplayer (2-player so far) game based on built-in Network Manager (based on this great tutorial https://unity3d.com/learn/tutorials/s/multiplayer-networking) and I have absolutely no idea how to solve my problem. Every tutorial I found about scoring systems was focused on local multiplayer game (not using Network Manager).
My question is:
How to display both players score on each player's UI in format like [Player1Score : Player2Score] if I store player's score in their instance of player's prefab (as a field).
I would like to display the scores in any way, as separate or as one appended string (UI text).
Any help and ideas are welcome!
Cheers!
Well basically , as far as i know , you firstly need a controller (server side) which keeps the score.
Then through Syncvar and RPC you can propagate to clients the score you need.
The logic there is at your choice , for example you might use delegates everytime a point is scored (it will depend on your game), and synchronize the variable.
https://docs.unity3d.com/Manual/UNetActions.html
I do not know what your case is? But can I suggest using Socket to transfer data between client and server. From there it is possible to display each side's scores to the opponent.
Via https://learn.microsoft.com/en-us/dotnet/api/system.net.sockets.socket?view=net-5.0
I've looked at the examples that come with the airconsole plugin, and in both of the examples the "meat" of the code is in one script.
I am interested in trying to make a multiplayer game, is it possible to split the control of each character into 4 scripts, which each are applied on a different player object rather than having one script control all 4 objects from one single script?
If so, how do you go about doing it, just by including the libraries in each control script? like so:
using NDream.AirConsole;
or do i have to do some kind of special structure?
It's possible to have various different scripts that use the NDream.AirConsole namespace, yes.
Be aware however that if you have 4 scripts in a scene that all listen for the OnMessage event, for instance, you will likely end up using a lot more performance than if you just have one "AirConsole script" in a scene, where you receive and filter the messages and then relay to the right player.
Better to have one AirConsole script that listens for the event, check for device id/player number in the OnMessage (or whichever) event and then send the relevant information to the player script in question.
That's how we do it for our multiplayer games in Unity.
I'm starting the development of a multiplayer game for iPhone/iPad and i was thinking of using Tigase as XMMP server for the game server. However it seems like Tigase not yet implement MUG XEP. Anyway MUG is too complex for the simple task i'm trying to achieve so.
Here is the game basic:
Each Match may have up to 4 players.
Each player may perform at any moment a move and the only game rule is to forward a packet to each player in the match that tell the move the user mades and weither or not is is a good move or not.
Here is the way i want to implement it:
Reuse the MUC component to simulate the Multi-player room.
Each room will have a Bot member: all packet will me addressed to that BOT directly: the BOT will check the moves (which will be basic message packets) for validity and sent the appropriate message to all Player in the room.
I think this may work. If you think this is a viable solution:
What is the best way to write the BOT. Should i have one BOT per room? how can i detect when a new room is created so i can create the BOT?
Apparently, the most simple way to do this is to build a plug-in to the MUC component. The MUC and MUG components are very similar so it provide most of the mecanism a multiplayer game needs.