Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Multiplayer Card Game

Discussion in 'Multiplayer' started by moh05, Jul 26, 2016.

  1. moh05

    moh05

    Joined:
    Nov 26, 2015
    Posts:
    65
    Hello guys,

    I know this topic has been discussed a lot, but I want to check the best solution for my case.

    I finished doing a game similar to hearthstone. The single mode is working fine.

    I want to add the multiplayer feature now. Details are:

    1- Log in with username and password

    2- Save players stats

    3- Shows leaderboard depending on number of winning matches

    4- User selects multiplayer mode, and waits till another player joins ( its only 2 players max)

    5- For the server/game logic, I just need the server to send a bit of information ( card id, player id,) and the AI will move the card and control the card's function.

    So what do you suggest me to use? Unet? Photon?

    Thank you :)
     
  2. Kamil-Says

    Kamil-Says

    Joined:
    Jun 30, 2014
    Posts:
    154
    Photon realtime and your own database for login and player stats. Since it's room based plugin it's perfect for your project.
     
  3. moh05

    moh05

    Joined:
    Nov 26, 2015
    Posts:
    65
    By own database you mean i need to have a dedicated server?
     
  4. Kamil-Says

    Kamil-Says

    Joined:
    Jun 30, 2014
    Posts:
    154
    MySQL & PHP database to store player account his stats and so on.
     
    moh05 likes this.
  5. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    With UNET, you can have:

    - Player-hosted games using Unity Services relay servers and matchmaking. This avoids the need for having a dedicated server but is less secure (the player hosting a game could be using a malicious client) and you need to pay for the services.

    - A dedicated server of your own that manages all the games. This is ultimately the more secure approach to prevent hacking, but you need to create your own server (and take care of the hosting) which, among other things, includes creating your own matchmaking system.

    Which approach is best will depend on several considerations specific to your studio and project (e.g., type of game, expected number of players, team size, familiarity of the team with server-side technology, budget, etc.).

    I use UNET in CCG Kit, where an optional Node.js + MongoDB server providing a REST-based API for player authentication, remote persistent data, card packs purchase and rankings is also included. But there are definitely many other options that are also suitable for this purpose.
     
    moh05 likes this.
  6. Monument2Sin

    Monument2Sin

    Joined:
    Oct 28, 2015
    Posts:
    2
    Hey guys, I've used GameSparks to run hearthstone like logic all on cloud. It uses the Matchmaking and Challenge system, and can easily incorporate leaderboards into it too. My approach means housing all the game's logic on the cloud while having the front end just reflect the data passed in from the backend (If card A2 from the player's playing field attacks card B3 from opponents field then display that appropriately in the front end).

    The entire game can be tested on GameSpark's platform without using a frontend. The data can then be sent to Unity, Unreal, Marmalade, your own custom engine (provided it can integrate the SDK) etc and displayed however you like.

    I've written a tutorial on how to do this using GameSparks on our doc website, if you want to check it out:

    https://docs.gamesparks.com/tutorials/multiplayer/hearthstone-example/

    It's an advanced tutorial that takes into account knowing a little about GameSparks, but couple that with the beginner's guide to Unity and it becomes rather straight forward.

    https://docs.gamesparks.com/getting-started/creating-a-game/unity-setup.html
     
    moh05 likes this.
  7. moh05

    moh05

    Joined:
    Nov 26, 2015
    Posts:
    65
    Thank you guys!

    What about:

    1- Adding friends

    2- Challenging friends

    3- Chatting

    Is it feasible with Unet or Gamesparks ?
     
  8. Kamil-Says

    Kamil-Says

    Joined:
    Jun 30, 2014
    Posts:
    154
    Photon has it all :)
     
    moh05 likes this.
  9. moh05

    moh05

    Joined:
    Nov 26, 2015
    Posts:
    65
    Hi there,

    Can you suggest a good video tutorial where I can start learning ? thank you
     
  10. moh05

    moh05

    Joined:
    Nov 26, 2015
    Posts:
    65
    Hey there,

    the Hearthtone tutorial looks a bit advanced. Do you have any link for any video tutorials I can read and check? Thanks
     
  11. Marceta

    Marceta

    Joined:
    Aug 5, 2013
    Posts:
    177
    I've been working on multiplayer games lately, i highly recommend you Photon. I've used Photon and Digital Ocean server for hosting php files and database.
     
    moh05 likes this.
  12. Monument2Sin

    Monument2Sin

    Joined:
    Oct 28, 2015
    Posts:
    2
    Sure thing, we're currently over hauling our platform's look. When that's done, wel'll be pushing a lot of video tutorials out. Hearthstone will be among them.
     
    moh05 likes this.
  13. moh05

    moh05

    Joined:
    Nov 26, 2015
    Posts:
    65
    Thanks,

    I really need a technical online support, do you guys offer that? Thank you
     
  14. moh05

    moh05

    Joined:
    Nov 26, 2015
    Posts:
    65
    thank you for your reply.

    Do you recommend using "turn-based" or "realtime" approach?
     
  15. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,021
    Turnbased and Realtime are more or less the same in Photon, as the API is the same. The main decision is if you need the game to be asynchronous or not.
    For most card games it should be fine that a game gets played in one session. That saves you some extra work, as you don't save a gameplay state.

    You can use PUN on the client side. Send playing a card as RPC and if needed, store the game's progress in Custom Properties.