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 tressix · Mar 07, 2014 at 04:16 AM · multiplayernetworknetwork.instantiateteamsgroups

How to use Network.Instantiate Groups

I'm trying to use groups in my Network.Instantiate calls to only create objects for some of the connected players. The unity documentation as I understand it states that's the purpose of the groups:

"Communication groups can be used to select the clients that will receive particular messages..."

What I think I'm missing is an example of how to set the network group of a player (the server can be a player too).

I've tried used Network.SetReceivingEnabled and Network.SetSendingEnabled in as many ways I can think of with no effect.

Ultimately I want to be able to Network.Instantiate on group 0 for all players, group 1 for a subset of players (team 1), and group 2 for another subset of players (team 2).

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by fifthknotch · Mar 07, 2014 at 04:21 AM

You specify what group number inside as one of the parameters of Network.Instantiate.

static function Instantiate(prefab: Object, position: Vector3, rotation: Quaternion, group: int): Object;

Check out: http://docs.unity3d.com/Documentation/ScriptReference/Network.Instantiate.html for more info.

Comment
Add comment · Show 10 · 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 tressix · Mar 07, 2014 at 04:27 AM 0
Share

I understand that, but how do I set the group on a connected player? Say I call Network.Instantiate for group 2, how do I set which clients are in group 2?

avatar image fifthknotch · Mar 07, 2014 at 04:33 AM 0
Share

When you Instantiate the clients, are they instantiated to group 2?

avatar image tressix · Mar 07, 2014 at 04:39 AM 0
Share

When clients connect to the host I'm not seeing a place where I can set which group they belong to.

avatar image fifthknotch · Mar 07, 2014 at 05:04 AM 0
Share

So, I have a network game I made, and in my script that connects my client to the server, it loads a lobby. When my game starts, all clients Instantiate a player and that is where the group number would be assigned depending on what $$anonymous$$m there are on.

avatar image tressix · Mar 07, 2014 at 05:15 AM 0
Share

Interesting. I have the same setup where each player will instantiate a prefab when the game starts. So you're saying when that initial Network.Instantiate call is made for each player's character the group number in that Network.Instantiate call is setting the network group for that player? Could you post the line of code that assigns the group number? Seems very unintuitive but I'll give it a try tomorrow.

Show more comments

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

21 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 avatar image avatar image

Related Questions

How to let the other network player to see a launched rocket and its explosion? 1 Answer

Mix unity Network Manager with own network script 1 Answer

Animation & sound over network 1 Answer

Instantiate By ID? 0 Answers

Testing my multiplayer character offline 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