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.
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.
i just wanna start to codding more clean and dynamic codes and i start to learn "events" but im so confused about events because all videos show different things 0.0 did i understand wrong or there are three types of events ? i mean
c# event
unity events
game events
if i understand true this all different event systems right ? and i can use which i want, and i should spesific.
i hope i understand right can someone explain shortly ? if i understand right just can say yes :)
There are UnityEvents. Usually AddListener(YourFunction)
There are Unity Events (meta, haha!)
There is an official Unity Tutorial on C# Events. Usually with the += operator: .OnClicked += YourFunction;
There is an Event System for the "Unity UI 1.0.0" Package, but there is also still the old Event System for Ui/Canvas interaction (until Unity 2018?).
There is the Event System for UI inside of Unity, if you want to build an Editor Tool, to paint prefabs in the Scene for example.
The "old" Input System (Input.GetKeyDown("Space")) is also an Event System.
But there is also a still optional, new Input System Package that handles local Coop (multiple Controllers) a bit better. You can only use one at a time. (You have to switch form one to the other in Settings)
As you can see, there a a lot of Event Systems. You can write your own, if that is required for a Task. Event Systems are a general way to handle changes without polling and comparing values every frame, but listening to changes and occurances.
What I'm trying to make
Hi, game development newbie here. The game I am trying to make is fairly simple. It's almost exactly like the old FC game "Ballon Fight" except that I'm trying to make it online where players can go through a match making to find opponents.
BalloonFight:
What I Read
I have read some articles, and found most of them lead to two approaches:
Put all game logic on the client, and the client sends player inputs to server on every frame update. The server acts like a dispatcher which only makes sure player A's input is received by both client A and B. My understanding is that if we see the client in this case as a pure function, and if the two players' inputs are received by each other, the game should produce same results on both clients. Thus synchronization is achieved.
Put all game logic on the server, and let the server do the calculations and send back results to both clients. In this case, clients only worry about displaying.
My Fears
Solution 1 sounded like a simpler one to me, but immediately I realized when network problem is put into account, it becomes incredibly complicated. Losing player A's connection for a few seconds means all the input is lost in that period. What I can guess is, to counter that, the server has to detect whether player A is lagged out and accumulate input from player B until player A is back then feed all the accumulated input to player A's client. Player A's client then need to do a fast forward to catch up. This sounds like there's huge amount of infra work on both client side and server side.
Solution 2 on the other hand looks very daunting to me, since for now I have only written some games on the client side.
My questions
in order to make a simple online game like this, what is the most beginner friendly way to synchronize game state?
if I were to use solution 1 stated above, is there any framework that provides such infra so that I don't have to handle network issues all by myself?
In advance, thank you game dev gurus.
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.
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.