I'm making multiplayer game on Unity with Mirror, and I want to add a timer (if it equals 0 then game ends).
Does Mirror have any integrated timer? Maybe I need do it myself?
Related
I'm looking for advice on how to implement online chess move validation using a winboard chess engine. I am creating a mobile battle chess game in Unity 2020.3. Right now I have the possible moves for each player, castle rights, check status, etc being generated by an open source C# chess engine. I chose this engine because it's written in C# and the code could be directly included in my Unity Project. I successfully wrote my own code that connects this chess engine to a 3D battle chess game.
How the game works (video preview):
A piece is selected by the player clicking it with their mouse or
tapping the screen.
The possible moves for the current board are calculated by the chess engine.
I use the possible move indexes to show possible move highlights.
When a player makes one of these possible moves, the move is applied on the chess engine.
It becomes the other player's turn.
I have some custom code to run player animations, based on the kind of move (ex. an attack animation runs when a piece is captured). I also show have screens that show when it's time for a promotion, a player is in check, or the game is over.
I'd like to somehow make the process of calculating possible moves and applying moves to be done on a server. My goal is to protect from players sending illegal moves to the board and breaking the game.
How would you recommend I approach this problem? This is the last thing I need to turn this game into an enjoyable online experience. I just lack the crucial skill of understanding how to make this game online.
On the server, you'll have a separate version of the chess game running.
A player(/client) will send a move to the server (so a unique piece ID, and the target square the player wants to move).
On the server-side, you'll need to check to see if that move is indeed possible. This could be by getting all possible moves from that piece, and checking to see if the intendedChessPosition can be found in the list of possibleChessPositions that was calculated on server-side. Only then, will you actually move the piece server-side.
All players/clients will communicate using the server as the middleman and authority.
The exact implementation could change depending on the API of the chess engine you're using, but that's the basic idea.
I am making a game in unity and I want to add motion blur visual effect. Which components are required to do that and is any scripting required? If yes, can anyone give an idea?
Also, I need to know how to toggle it through UI.
Go to your package manager in unity, add Post-Processing.
After that create a new post processing profile in the assets and add motionblur to that. Create a post processing volume in ur scene, set it to global and select the posyprocessing profile. Finally place a post processing layer on your camera and set the layermask to everything.
[Unity Post-Processing Documentation]https://docs.unity3d.com/560/Documentation/Manual/PostProcessing-Stack-SetUp.html
Im working on a demo project, where I use Unity 3D and Photon Unity network(PUN) for a real time game.
The person in the top panel is an enemy unit, controlled by another player who does damage to the player on the bottom left (1/3 hp left).
However, the person on the bottom right is a healer who can heal the bottom left player (both controlled by the local player).
Here's my problem! Since it isn't turn based and has to happen real time. How do I design my multiplayer system? Ive previously worked on turn based games, where I just pass the indices and mirror the events taking place locally, in the remote player as well.
But here with latency in the picture, I do not know how to proceed!
What I would like to do is, have the healer heal the player locally as well on the remote player's phone before he is attacked by the remote player or kill the player before the healer can heal his hp depending on the timestamp in which the events happen and reflect such on both the devices.
I think you are confused with some of the pun networking features.
If the healer heals your local player, so will be the remote instances of your local player. Your healing system must be networked of course, make sure you go through our basic tutorial to learn how to implement a simple health system.
https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/player-networking#health_synchronization
What will be slightly more complex than health management is the switch between your player and healer locally. for this you have two main variants.
transfer ownership between the player and healer: https://doc.photonengine.com/en-us/pun/v1/demos-and-tutorials/package-demos/ownership-transfer (this is a v1 demo but the principle still applies to v2)
have a invisible network player, and using your own logic in your game, have the player matching this invisible network player or the healer matching it.
Is it possible to use Unity as a render engine? I have a game which is written in C# and I would very much want to rewrite it to use Unity because of it's portability and use of C#. The game itself is a 2D maze game (think Pac-man).
I read alot of tutorials for using Unity for 2D games but all of them used almost only menus and editors which embedded in Unity and used only small portion with C# or other programming language. If I'm going to go down this road it means I need to "rewrite" my whole game logic with Unity's editors/menus/managers etc...
I'm looking to use it like the XNA library for example. Is there any way to achieve that with Unity? If not, is there another game engine/library using C# which is cross-platform and canm be run under mobile devices?
I made Fangz (https://www.youtube.com/watch?v=x6-5D6IkD5E) using Unity. If that doesn't prove that a complex 2d game can be made in Unity, I don't know what does :).
You can use Unity like XNA, but that would deny you from Unity's strengths. Once you get used to visualising your member variables in an editor in a custom way (via inspector editor scripts) it'll be hard to go back :).
Furthermore Unity now has native 2d support, which is as good is not better as 2d Toolkit, once of the most well designed 2d packages I've had the pleasure of working with.
Another advantage of Using Unity is that you'll be able to easily add animations to your 2d game. Just add an animation component, press record and move.
All in all I find myself thinking the other way around: how can anyone do a 2d game in anything other that Unity :).
I'm just C# newbie C#, and I'm trying to build a Tic Tac Toe game in Windows Forms in which player will play with the computer. Each one will have to make their move in a certain amount of time. If they don't, the turn will skip to the opponent. Here is the tricky part. When it comes to the computer's turn, I wanna disable the player action, so he cannot interfere with the computers. Is it possible to do that ? and how would I implement in my code ?
Edit: I didn't realize that the computer move is almost instantly, so it does not matter if I disable the player or not. Thanks anyone for your inputs.
You can include the play area inside a Container eg: GroupBox and disable/ enable it depending on the requirement. This has to be on the UI thread. Just a suggestion.
With no code its hard to see where you are at.
Just use a Boolean and an if statement to disable player interaction if it is the computers turn.
A Boolean to detect if its the computers turn.
A if statement to disable player interaction if it is the computers turn.
if(computersTurn==false){
Allow UI/Clicking
}
You can do a pause according to voddy's answer, but any computer pause would be purely for effect as Derek mentioned. One simple thing you could do is to just create a timer, and when the timer event fires regularly, switch to the opponents turn and/or disable the UI as required.