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 DeadKenny · Nov 16, 2013 at 11:01 PM · collisionerrorcollidermultiplayerplayer

Multiplayer Layers and Colliders confusion.

Ok so how would I avoid different players having things like raycast and so on colliding with specific things that are only meant for the specific player?

Like in my case I have a box collider around the player which detects certain things like a ray which is cast from the player. So I want to make sure that other players raycast also does not hit it and cause problems.

How to avoid it?

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 Tomer-Barkan · Nov 16, 2013 at 11:18 PM

One way would be to have different layers for different players, and then setting up the layer collision matrix so that the different layers do not collide with each other.

A second option would be to have an owner id in the scripts, and then checking in OnTriggerEnter() whether the item collided with belongs to the correct player. This will only work on trigger colliders though, since non-trigger collisions will be resolved by the physics engine (the layer collision matrix will work for both)

Comment
Add comment · Show 3 · 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 DeadKenny · Nov 16, 2013 at 11:48 PM 0
Share

Well the collider is a trigger. What I mainly(if not the only) thing I want to avoid is other players raycast hitting it.

Ok so how would I get each new players collider into its own layer... Or give it a unique ID like you say?

The second option seems better, would it also be better on the cpu?

avatar image Tomer-Barkan · Nov 17, 2013 at 08:00 AM 1
Share

See the link in my answer to find out how to set the layer collision matrix, and tell unity which layers may collide to which other layers.

See this link about how to define and assign layers to objects:

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

The second option requires a bit more calculations, since the collision takes place and only when handling it do you decide to ignore it. Not sure how much worse though, you could do some benchmark testing to find out... If the layer matrix works for you, use it, it also requires less code.

avatar image DeadKenny · Nov 17, 2013 at 08:18 PM 0
Share

Oh ok I think I know what to do now...

Set the raycast to only hit a certain layer and give each players vision box its own layer which will be the layer per player.

Confused myself a little on how to do that but I'll ask that later.

Ok.

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

18 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

Related Questions

When using URP, colliders stop working 2 Answers

Error CS1061 I can't find a solution! [C#] 1 Answer

Collision bug. 2 Answers

How do you make collider interactions and movement smooth? 0 Answers

No Collision 3 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