Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 tallesmaziero · Jul 20, 2018 at 06:19 AM · triggerrigidbody2dcollider2d

Enemy falling through floor when i have a rigidbody and a collider set to trigger

I googled it a lot but i was unable to find a solution to this.

i have an enemy and i attached Rigidbody2D to it, it patrols an area and has to go up and down slopes, that's why the rigidbody2d is attached, to use gravity.

At the same time a want to use with it a CircleCollider2D as a trigger, to have combat.

I need my player to pass through this enemy.

But at the moment i set the collider as a trigger my enemy falls through the floor.

The floor also has a composite collider on it and a rigidbody2d.

There is any way to work around this?

ps: i'm using c# if i need any coding.

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 Piyush_Pandey · Jul 20, 2018 at 06:29 AM

If an object is having a collider with IsTrigger enabled, it will not act as a solid shape even though the rigidbody is attached. Instead it will work as a trigger volume. What you can do is:-

1) Create an empty child of player

2) Attach another CircleCollider2D to it and mark it as isTrigger enabled.

3) Use this for triggering the enemies.

4) Disable the isTrigger of the players main collider.


EDIT: sorry i missed the Enemy Part. For that you can add different layers to Player and enemy. You can check here. Now got to the project settings->physics2D and disable the collision between the Player and the Enemy layers. In this way, they will not collide with each other.

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 tallesmaziero · Jul 20, 2018 at 11:23 PM 0
Share

Fantastic! Now it worked! i was already using layers but forgot about the physics 2D in the project settings. i placed a empty object with a trigger collider as a child of the player and the combat is still working too.

avatar image Piyush_Pandey tallesmaziero · Jul 25, 2018 at 07:27 AM 0
Share

Happy to help.

avatar image
0

Answer by tallesmaziero · Jul 20, 2018 at 06:42 AM

Thx for your reponse.

I've already tried to do this, but the problem is that my player pushs the enemy and i can't pass through it.

Comment
Add comment · Show 4 · 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 tallesmaziero · Jul 20, 2018 at 06:45 AM 0
Share

$$anonymous$$aybe if i can enable gravity without a rigidbody on my enemy it will work. but i don't know how to do this without a rigidbody or a character controller.

avatar image Mr_Teels · Jul 20, 2018 at 07:10 AM 0
Share

You can add multiple Collider to a Object! One for the Trigger, one for the collision

avatar image tallesmaziero Mr_Teels · Jul 20, 2018 at 07:20 AM 0
Share

I tried that. But it don't resolves the problem of not passing through my enemy. The "not trigger" collider prevents it.

avatar image Piyush_Pandey tallesmaziero · Jul 20, 2018 at 09:21 AM 0
Share

please check my edit of the answer

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

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

Related Questions

Apply Rigidbody/Colliders on EventSystem or Prefab Itself? 0 Answers

2018.2.17 OnTriggerEnter2D not working 1 Answer

[SOLVED] How to Destroy a rigidbody game object on collision with another gameobject? 4 Answers

Turning off trigger with multiple box colliders? 0 Answers

Is there any way to increase a triggers check rate? 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