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
0
Question by HarryMoran327 · Jun 28, 2013 at 05:31 PM · c#prefabmultiplayer

Help for LAN multiplayer in C# ?

Hey guys

I'm almost finished my new game, and the only thing left to implement is the LAN multiplayer. I've found loads of great tutorials on this for JavaScript, but some of my game, such as the play button and player, use prefabricated C# code. I was wondering if anyone with some experience in this could please help me with this? I need to have the game finished by tomorrow, so a quick answer would be really appreciated :) Here's the code for the start button for some reference:

 using UnityEngine;
 using System.Collections;
 
 public class PlayButton : MonoBehaviour {
 
     private bool _run = false;
     private PlayerControl _playerControl;
     
     void Start(){
         _playerControl = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerControl>();
     }
     
     void OnGUI () {
         if (_run == false && GUI.Button (new Rect (Screen.width/2-125,Screen.height/2-35,250,70), "Play")) {
             _playerControl.status = true;
             _run = true;
         }else if (_run == true && GUI.Button (new Rect (10,10,100,50), "Stop")) {
             _playerControl.status = false;
             _run = false;
         }
 
     }
     
 } 

Thanks

Harry

Comment
Add comment · Show 5
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 Kiloblargh · Jun 28, 2013 at 05:35 PM 1
Share

I'm almost finished my new game, and the only thing left to implement is the LAN multiplayer.

Translation : "I'm nowhere near finished with my first multiplayer game."

avatar image HarryMoran327 · Jun 28, 2013 at 05:38 PM 0
Share

I think that's just a bit harsh. What I mean is that I've finished absolutely everything for one player, I just need a way to make the game multiplayer-capable

avatar image HarryMoran327 · Jun 28, 2013 at 05:39 PM 0
Share

So could the next comment please have something to contribute to this conversation? Because I really need some help with this! :)

avatar image Kiloblargh · Jun 28, 2013 at 05:58 PM 1
Share

Not trying to be harsh; I'm just saying that even starting with a completed single-player game, going from that to a multiplayer game is not going to be as easy as you think, and you're in trouble if you need it done by tomorrow. I don't know what your game is, I was guessing it's for a class project and it's something basic like a clone of Atari Combat or Asteroids. If your game is something trivially small and simple like that; then adding multiplayer and getting it working right might take more time than everything else you've done on it. If your game is large and complex, OTOH, and it was not originally scripted with multiplayer in $$anonymous$$d, adding multiplayer could send you back to the drawing board- so either way, you're probably not more than halfway finished.

avatar image tharealjohn · Jun 28, 2013 at 06:02 PM 0
Share

While I agree with the basic point that multiplayer games are more difficult than a single player game, for the most point, it really is just your opinion and it doesnt help the OP or answer the question. Even if you are 100% correct, which there is no way to prove, as it is just relative observations, it would be nice to at least answer the OPs question on unity resources to get him started, while at the same time giving him your "advice" on whatever you like. Thats how a community should give a "complete" answer while still encouraging.

1 Reply

· Add your reply
  • Sort: 
avatar image
4

Answer by tharealjohn · Jun 28, 2013 at 05:53 PM

Have you consider reviewing this area of the documentation?

http://docs.unity3d.com/Documentation/Components/NetworkReferenceGuide.html

It has a great walkthrough of all the concepts of basic client/server relationships in Unity. Unity also provides some nice classes (The Network class) in C# to get a basic LAN system going, where one of the game instances is considered the "server" and the others connect to it. You might have to reorganize some code, because implementing these things can change some of the decisions you make in places.

M2H also has a great reference on this, and some example projects. They used to be on the asset store, but Im not sure if they still are. You can google M2H Networking Tutorial to find them.

Comment
Add comment · Show 1 · 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
avatar image HarryMoran327 · Jun 28, 2013 at 06:03 PM 0
Share

Thanks, I'll look into that :)

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

16 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

Related Questions

Multiple Cars not working 1 Answer

Instantiate already connected players. 0 Answers

Distribute terrain in zones 3 Answers

unity tank tutorial added turret rotation. Problem both player controls move same tanks turret. 0 Answers

Not allowed to access Renderer.material on prefab object? 2 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