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 Mexallon · Dec 20, 2014 at 11:44 PM · physicsrigidbodygravity

Rigidbody (with Box Collider) falls through floor

Hej fellow Unity users!

As stated in the title of my question I got a problem with rigidbodies falling through the floor. I've done my homework and googled for it but the most answers were "turn isTrigger off" and "don't user mesh colliders". As seen on the picture below my bullets seem to rest on a plain inside my solid floor that has a box colider attached to it (that is not a trigger and is 2 units thick).

I spawn my bullets via code and attach a rigidbody and a box collider to them at runtime in a update function (could that be an issue?)

Bullets lay beyond the floor (orthographic side view)

I'm often struggling with the phsysics in Unity, seems we two got some problem, hope you guys can give me some hints.

The Code that spawns the shell:

     public void SpawnShell() {
         GameObject go = GameObject.Instantiate(ShellPrefab, ReferencePosition.position, Quaternion.identity) as GameObject;
         go.AddComponent<BoxCollider>();
         go.AddComponent<Rigidbody>();
         Parenting p = go.AddComponent<Parenting>();
         p.Parent = "EMPTY_SHELLS";
         go.transform.rotation = Random.rotation;
         go.name = "Empty Shell";
         //go.rigidbody.AddForce(0f, Force, 0f, ForceMode.Impulse);
         //go.rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
         Destroy(go, DespawnTimer);
     }

EDIT: still don't have a clue. I know there have to be some inaccuracies in order to perform in a certain speed but I don't know why this doesn't work :( no one any idea?

EDIT 2: I've set the "Min Penetration For Penalty" in the Physics Project settings from 0.01 to zero. Now it looks better but not quite perfect because the box colliders are still half in the floor

alt text

Regards Mexallon

shells_beyond_floor.jpg (35.3 kB)
better_but_not_perfect.jpg (169.7 kB)
Comment
Add comment · Show 7
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 ahmedbenlakhdhar · Dec 21, 2014 at 12:26 AM 0
Share

Can you show the script?

avatar image Mexallon · Dec 21, 2014 at 12:30 AM 0
Share

sure. updated the question

avatar image cwperkins83 · Dec 21, 2014 at 02:16 AM 0
Share

You said that you're adding the components in Update, but your code doesn't show that. Do you mean that you're calling the SpawnShell() in the Update?

avatar image EvilTak · Dec 21, 2014 at 03:02 AM 0
Share

If you are using 2d,then make sure that you use Rigidbody2D and BoxCollider2D and PolygonCollider2D ins$$anonymous$$d of Rigodbody, BoxCollider and $$anonymous$$eshCollider.

avatar image Owen-Reynolds · Dec 21, 2014 at 07:31 AM 0
Share

An easier way is to give the bullet prefab the collider and rigidbody. Then no need to add them in code, and you can adjust them in the editor (weight, drag, colliders often look better a little diff size than the object.)

Also makes it easy to position a bullet right above the ground, for a "test drop" on Play.

Show more comments

1 Reply

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

Answer by Mexallon · Dec 23, 2014 at 10:55 AM

I've set the "Min Penetration For Penalty" from 0.01 to 0 in "Project Settings->Physics". This seems to solve the problem more or less. As also stated in the comments I think the same way that the bullets may be to small or my physics settings are not properly.

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

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

30 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

Related Questions

How can i rotate player when player jump ? 2 Answers

Gravity is preventing object from moving straight toward its direction when calling rigidbody.AddForce... 1 Answer

Tornado throwing back force after pulling 1 Answer

Rigidbody unwanted drifting 3 Answers

Artificial Gravity 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