Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Coyote · Nov 23, 2013 at 11:58 AM · networkingnetworkservershootclient

Creating a multiplayer game.

I have been using Unity for a while now, and I have been learning how to create a multiplayer game for the past couple of days. I have gotten as far as creating a server, multiple people joining it and each user sharing their object data (position, rotation) using NetworkView. The method I used was to use a player as a host of a server, and have him host it until he leaves the game. This method really makes no sense, since the player can leave at any time and the game will be over. I was wondering how could I create a different scene, or maybe even a different project to use it as a server and have it only share data. Like RPC commands, calculating if a player has been hit by a bullet etc.

Here's an example: Player 1 presses down the mouse button while aiming at another player. Player 1 then sends out an RPC call to the server telling it it's location and the point at which the player is looking at. Then the server decides if anyone has been hit, if so, take away health from Player 2.

Using this method, I would have to re-write every single function used by both Player 1 and 2, so I can use it in the server script. If that makes any sense.

Maybe i'm just being dumb and missing out on something really simple. I've seen really good multiplayer games created in unity. What is the most common way to share data between players and what approach should I take?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image srylain · Jun 22, 2016 at 06:22 AM 0
Share

The more game logic the server itself runs, the less can be hacked or cheated. If the server controls who shot who and for how much damage, someone who cheated their client wouldn't be able to do anything with the modified client. Look into the problems with The Division, since $$anonymous$$assive decided to do most everything client-side. This opens up to letting people have infinite ammo, more damage than they should have, flying/teleporting, and etc.

$$anonymous$$ost games also make the server rollback time to the time that the player shot to line up the shots to see if it hit. If you don't do that, you have to lead your shots (watch or play any game from before the late '00s for examples really) while making the server rollback time allows each player to shoot at the other players directly. Lag is always a problem when playing online games, but you still want to make sure the game works as well as it can.

If one player were the server though, you'd have to deal with NAT. NAT makes it so people can't connect with each other, so you'd have instances of people not being able to play with others. Servers get around all that by just not having to deal with NAT, but since most everybody in their home is connected through a router they have to. If you had dedicated servers (or paid for the Unity's relay systems) you'd be able to connect damn near everybody on a pretty close to 100% of the time.

Plus, that player's computer would need to run the server as well as his game which could potentially make it so that some people couldn't play if they had weaker hardware. Games that are very small in player count (like 1v1 fighters) are better off if they connect straight to each other (less lag), but when you start getting into higher player counts you need servers to keep it as fair as possible for everybody.

Just look back into the original Gears of War's lag problem on 360 (and Gears 2 as well). You could easily tell who host was, and host always had the upper hand due to no lag.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Tsurugi21 · Jun 22, 2016 at 06:00 AM

Dedicated servers are quite simple really (at least the way I create them). They are just an instance of the game that doesnt spawn a player object (and thus dont play). Of course, if this is a matchmaking server, a masterserver would be a smarter choice. (please dont use unity's, it almost never works for me)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Very Confused on Networking HLAPI Practices 1 Answer

Do i need to have 2 seperate apps communicating for server/client relationship? 2 Answers

"Trying to send command for object without authority" warning but the object is the localPlayer 1 Answer

All players number in Network 1 Answer

Question regarding Server-Client approach in Unity 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges