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 mykolak · May 31, 2013 at 08:16 PM · 2drigidbodycollidermultiplayer

How do I get two objects (both with rigidbody and colliders) to pass through each other (and only each other)?

Hi friends!
I am making a 2d side scrolling game. It is two player locally, and I obviously need both players to collide with their environment, so that they can't walk through walls and such. This was easy to accomplish, but now I have hit a snag. The players, both having rigidbody and colliders, run into each other. I want them to be able to pass through each other so that the players can pass each other. How can I make it so that the players still collide with the floor and walls, but can pass through each other as if they didn't have colliders or rigidbody? Any help is greatly appreciated!

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 Jamora · Jun 01, 2013 at 09:00 AM

This can be achieved with physics layers. Just put your players on different layers, then use http://docs.unity3d.com/Documentation/ScriptReference/Physics.IgnoreLayerCollision.html to tell Unity to not collide them with eachother.

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

Answer by Supershandy · May 31, 2013 at 08:37 PM

Where you use OnCollisionEnter or OnTriggerEnter, just specify which items it can't pass through using tags.

i.e

Tag "Wall" with "Wall" in Inspector

Then in player code....

var velocity : float = "Something";

function OnTriggerEnter/OnCollisionEnter ( col : Collider )

{ if (GameObject.FindWithTag("wall")} { velocity = 0; )

}

That example will mean that if it hits something with the tag "wall" then it can't pass through it. Anything else it will pass through.

Hope this has been of some help and help you move in the right direction.

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 mykolak · May 31, 2013 at 09:07 PM 0
Share

Wait, this confuses me a little bit. What should i put in place of "something"? The starting velocity? This doesn't seem to work for me... Forgive my ignorance.

avatar image Supershandy · Jun 01, 2013 at 08:35 AM 0
Share

where it says "Something" means just to put whatever value you want in there i.e var velocity : float = 1.5;

How do you mean it doesn't work? How are you working out your collisions?

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

Dealing with 2D movement and collisions! 1 Answer

Continuously moving rigidbody 2 Answers

is it better to make one collider for a large landmass made of many tiles, or make each of the tiles have their own colliders? 2 Answers

My 2 Objescts doesnt collide 1 Answer

How to make rigidbody bounce off the mouse? (2D) 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