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
2
Question by Muhwu · Dec 28, 2013 at 02:18 PM · rigidbody2d-physicscollisiondetection

2D collision detection without rigid body?

I have a simple game where I require a certain amount of collision detection from my models. However, I do not need physics in this so the checks are actually mostly just box checks or shape checks which need to trigger an event.

I got it to work using RigidBody2D + BoxCollider2D on the colliding object and BoxCollider2D (With isTrigger set to true) on the other one.

I do my translations currently using translate rather than physics (Time will tell whether I will do it like this in the end as well).

So my question is that is there a way to clip the Rigid Body out of the whole equation. I feel like the current model is a bit silly given that I have a Fixed Angle rigid body (All game characters will be like this and there might be many so this creates overhead?) objects with all the variables set to 0.

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

3 Replies

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

Answer by Spinnernicholas · Dec 28, 2013 at 06:10 PM

Yeah, you can drop the rigidbody and just do everything with colliders. Then you can respond to events OnTriggerEnter2D, OnTriggerStay2D, and OnTriggerexit2D.

Comment
Add comment · Show 8 · 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 Spinnernicholas · Dec 30, 2013 at 07:34 PM 0
Share

Thank you, thank you.

avatar image vian · Jan 28, 2014 at 03:32 AM 1
Share

Hey man, I tried those mothods using only colliders, but it just wont work.

The only way I managed to make it work is using a rigidbody as $$anonymous$$uhwu said. Can you elaborate a bit more on how you have done?

avatar image vian · Jan 29, 2014 at 10:06 AM 1
Share

Yes I'm using the new classes for 2D content. Right now the game is behaving as I want, but like I said, it's weird being forced to attach a rigid body. Before I found this post I already felt like I should be able to do it with colliders and those methods you pointed out, basically after you post I just retested everything I had already done hehehe.

avatar image Spinnernicholas · Jan 30, 2014 at 05:27 PM 1
Share

Yeah, that verifies it, one of the two objects needs to have a rigid body. You can just have rigid bodies on you characters/entities and not on your environments.

avatar image Spinnernicholas · Jan 30, 2014 at 05:28 PM 1
Share

I don't know why he selected my answer if it doesn't work.

Show more comments
avatar image
8

Answer by DiegoGomez87 · Aug 03, 2016 at 06:38 AM

Hi, Maybe this is not the best approach and probably you are not expecting this answer anymore, but someone like me could reach this thread and this could be useful for him: If you add a rigidbody with "Is Kinematic" = true and set the box collider with "Is Trigger" = true you can detect collision using the following code:

void OnTriggerEnter2D(Collider2D other) { }

Hope this help

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 KaffeSumpen · Nov 02, 2016 at 08:48 PM 0
Share

This should be the correct answer

avatar image unity_iqpjoab7nxtwOQ · May 23, 2020 at 01:38 PM 0
Share

Worked for me. Thanks.

avatar image
5

Answer by JiajieXu · May 26, 2017 at 04:17 PM

The answer of Spinnernicholas is not correct!

You need at least one rigidbody2D attached in the collision of two colliders.
To improve the performance is a good practice attaching the rigidbody2D to the moving gameobject, and leave the static collider without rigidbody.

some useful links are:

  • https://unity3d.com/cn/learn/tutorials/topics/2d-game-creation/collider-2d?playlist=17093

  • https://docs.unity3d.com/Manual/class-Rigidbody2D.html

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 gugelscriber · Jun 02, 2018 at 02:34 PM 1
Share

This worked, Remember not to turn "simulated" off.

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

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

Related Questions

player jumps too high when clicking with two fingers. 1 Answer

Preventing Rotated Jumping (C#) 1 Answer

How to check if rotating an object will cause a collision? 2 Answers

object passing through walls and floors 1 Answer

Stop rigidbody2D or change direction 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