Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 NaXDy · Aug 06, 2015 at 05:19 PM · collisionphysicsnetworkingmultiplayergroups

Make objects collide only with other objects of same type

I realize that the title may be a bit confusing, but I just didn't know how else to phrase it.

Here is the situation: I am developing a multiplayer game where every player controls a set of objects. These objects can collide with one another and are not supposed to intersect (basically like ordinary physics with a rigidbody). They can, however, intersect with and pass through objects that are being controlled by other players.

To put it in another way: Player A controls N objects that are labeled "A-Object1, A-Object2.... A-ObjectN" and player B controls a different set of M objects that are labeled "B-Object1, B-Object2... B-ObjectM". A-Objects treat other A-Objects like regular colliders (e.g. floor, walls, etc.), but treat B-Objects like thin air and vice versa.

In a real environment, this scenario would NOT be limited to just two players, but rather a theoretically infinite amount of players. On top of that, the server will be authoritative, meaning that it will have the last word regarding collisions and/or pass-throughs.

How would one go about implementing such a functionality?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by NaXDy · Aug 07, 2015 at 11:36 AM

I think I may have found a solution.

What I'm doing now is using the effects of 'Physics.IgnoreCollision' in a way so that I check in 'OnCollisionEnter' if the object is from the same player. If not, I add it to the IgnoreCollision part.

It's a rather dirty solution in my opinion, but it does seem to work, even with infinitely many players.

Comment
Add comment · Show 2 · 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 AlwaysSunny · Aug 07, 2015 at 03:22 PM 0
Share

Whoops! I always forget about IgnoreCollision! It's obviously not as CPU-friendly as a layer-based method (which ignores collisions before they happen) but darn if that's not a way to get what you asked for. I apologize for the misleading answer,

avatar image NaXDy · Aug 07, 2015 at 03:24 PM 0
Share

It's alright. As the collisions will probably be handled solely by the server, I'm not too worried about CPU anyway, so that should be fine. Your suggestion might prove useful for other projects though, so thanks anyways!

avatar image
1

Answer by AlwaysSunny · Aug 06, 2015 at 05:21 PM

There is no trivial way to do this with an "infinite" amount of players. You would need to bypass Unity's PhysX / Box2D physics systems altogether.

It may be that you can import an unwrapped version of Box2D (or another 2D or 3D physics library) to Unity, and bypass any limitations Unity's wrappers have imposed upon that system - potentially, any matter-of-course finite independent layer limitation.

Other than that, it's time to start looking at hacky solutions, changing your expectations, or something like a "shard" concept, used by many MMOs, where only N players are active in a concurrent shard instance, where N is less than the layer limitation.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Players can't move each other in multiplayer? 1 Answer

Layer Collision in Networks (Mulitplayer Game). 0 Answers

Unity networking tutorial? 6 Answers

UNET Network Transform Component lags 2 Answers

best way to make a multiplayer physics heavy game (3000+ rigidbodys) 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