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 shoopufff · Dec 30, 2018 at 01:40 PM · scripting problemcollisionrigidbodycolliderscollision detection

Rigidbody trapped in collider after collision

I am currently attempting to make an object collide with another and subsequently pass through that object. This implementation below works fine for objects up to a certain speed at which point they get trapped inside the other collider and struggle to pass through but cannot move even though they retain their velocity.

The collision is being detected with ray casting and I've confirmed it is colliding with the target as expected when it gets stuck.

Any help is appreciated. Thanks for your time.

 if (pierce)
 {
     Physics.IgnoreCollision(GetComponent<Collider>(), cb);
     //Stop from rotating after hitting the object
     rb.freezeRotation = true;
     rb.freezeRotation = false;
     //reset velocity
     rb.velocity = originalDirection.normalized * originalDirection.magnitude;
     //reset look rotation
     rb.rotation = Quaternion.LookRotation(rb.velocity);
 }
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
1

Answer by mlnczk · Jan 02, 2019 at 10:13 AM

So you got two objects both with colliders and you want them to pass through without colliding? If so then set one collider to be "Is Trigger" and if you want to do something while they touch their colliders you got unity's method OnCollisionTrigger(). If you got some setup that allows them to go through or doesnt depends on option then you can mark it as trigger by code simply by collider.isTrigger = true/false;

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 shoopufff · Jan 03, 2019 at 03:33 AM 0
Share

Hello $$anonymous$$inczk, thanks for the reply.

However for my particular issue it works with the above implementation for my colliders and triggers how I want it to and I'm trying to deter$$anonymous$$e why it begins to fail when the object is going faster because it still shows that it registers the collision and disables runs through the aforementioned code but for whatever reason it just stays inside the object afterwards ins$$anonymous$$d of passing through normally.

Is there something else I'm unaware of that the Physics.IgnoreCollision portion is incapable of stopping faster moving objects?

Edit: spelling

avatar image mlnczk shoopufff · Jan 03, 2019 at 08:15 AM 0
Share

Hi shoopuff! If you dont want those object to collide ever then go to Edit - Project Settings - Physics. You have squared with marks you can setup over there possible collision. Just uncheck boxes between those two objects so the engine knows whether to calculate collisions or not. Its also very good for optimalization.

avatar image shoopufff mlnczk · Jan 04, 2019 at 01:52 AM 0
Share

Unfortunately I don't want these objects to never collide and I'm aware of the layering system that Unity has to prevent them from doing so and am actively using it already. I want these objects to only stop colliding if they have that boolean set (Pierce) otherwise they should collide normally.

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

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

Related Questions

Strange issue with collider 1 Answer

How can I simulate a realistic collision between a metal axe and a door and prevent them from passing through each other? 1 Answer

Why when i move the player object through the door the ontriggerenter/exit event are not fire ? 2 Answers

Ragdoll with multiple colliders 0 Answers

Trying to make object turn red OnTriggerEnter 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