• 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 Kacer · Oct 26, 2011 at 10:11 AM · physicsboxcolliderbounce

Several box colliders stacked on top of eachother gives bouncing effect

Hello

I'm making a physics game (again, i love those things), but one thing i cant seem to get right in any of the games i've made so far is the collision effect, i've finally had enough as its become a too large hindrance in this game, so now im asking for help.

This game is basically about building a tower as high as possible by using boxes. there is an issue though, when i've got 4 or more boxcolliders stacked on top of eachother the physics engine goes bonkers.

The boxcolliders which are supposed to be solid, i've given them the metal material, are getting all bouncy, which means that if i drop a new box on top of the stack it bounces and then settles into place, i dont want this to happen. I've messed around with the physics settings but i havnt really found anything that helped.

Can anyone help me with this issue?

Thanks in Advance

  • Kacer

Comment
Add comment · Show 4
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 syclamoth · Oct 26, 2011 at 10:21 AM 0
Share

Is this like Bontago? You might want to manually code some of the details. When you drop something on the top of the stack, have a collision message which carefully resets its velocity so that no bouncing happens.

avatar image Kacer · Oct 26, 2011 at 10:47 AM 0
Share

I've never heard of Bontago, but from what i can see from various youtube videos its not the same :), $$anonymous$$e's just a simple build a tower game where you have to use a pressure sensor to grab the blocks and a kinect (if i manage to get hold of one) to move the blocks around.

the idea of resetting the velocity is a nice one, i'll just do some experiments with it, but in theory wouldnt it have the same effect as dropping a box from a low height?

avatar image Kacer · Oct 26, 2011 at 11:08 AM 0
Share

Well, it does work, to some extent, i cant do it with a collision detection, becasue then the boxes would already have hit eachother and the collision would have occured.

I have tried it with a raycast ins$$anonymous$$d that resets the velocity whenever there's a box within range, the problem with this is that there's still a small amount of bouncing going on, as i cant stop the box from falling completely by resetting the velocity.

avatar image Kacer · Oct 31, 2011 at 08:08 AM 0
Share

up this goes (cant remember if bumping is allowed on Unity Answers)

2 Replies

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

Answer by aldonaletto · Oct 31, 2011 at 06:17 PM

I tested stacking primitive cubes with mass 1 and they behaved as expected. There was a little bouncing when several blocks were stacked, which after some time made the tower oscilate until it fell to the ground (limit about 15 to 17 blocks).
I tried other materials, what didn't change the result too much, then I used brute force: attached the script below to the block prefab.

var damp: float = 0.01;

function FixedUpdate(){ rigidbody.velocity.y *= (1-damp); } This code damps the vertical velocity exponentially: in the example above, it reduces the vertical velocity 1% each physics cycle (50 cycles per second). You can adjust the damp factor to reach the desired results. It also affects the falling speed - but not so much: the blocks fall more like gigantic building blocks.

Comment
Add comment · Show 7 · 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 Kacer · Nov 01, 2011 at 08:17 AM 0
Share

thanks for the answer, im looking into it now, the only thing i'm having issues with, with this script is the limitation of c#.

I cant modify the y-value directly, so i have to write it like this:

rigidbody.velocy *= new vector3(1,(1-damp),1)

the issue here being that i cant multiply these two vectors, so now im just trying to figure out what to do.

avatar image aldonaletto · Nov 01, 2011 at 09:03 AM 0
Share

I'm a JS guy, but as far as I know this C# issue affects properties, like rigidbody.velocity. You can copy the property to an auxiliary variable, modify any of its components and write it back, like this:

float damp = 0.01f;

void FixedUpdate(){ Vector3 vel = rigidbody.velocity; vel.y *= 1-damp; rigidbody.velocity = vel; }

avatar image Kacer · Nov 01, 2011 at 09:07 AM 0
Share

Thanks, that was the code i came up with myself as well, but the effect still seems a bit odd, its like the speed is decreased by, if we say that damp is 0.3, then the speed is permanently decreased by 30%, and not 30% for each physics cycle.

edit:

yeah, with my physics settings a dampening of 5% gives a max velocity of -3.7, and a dampening of 30% gives a max velocity of -0.7, i might be misreading Aldonaletto's answer, but i dont this this is intentional?

avatar image aldonaletto · Nov 01, 2011 at 09:09 AM 0
Share

Another alternative:

   rigidbody.velocity = Vector3.Scale(rigidbody.velocity, new Vector(1, 1-damp, 1));
avatar image Kacer · Nov 01, 2011 at 09:31 AM 0
Share

oh, i never knew such a thing as vector3.scale existed, thats handy ^^

Thanks.

Show more comments
avatar image
0

Answer by SarutNai · May 16, 2012 at 05:39 PM

I try to deal directly with physic setting in PhysicsManager

Min Penetration For Penalty <-- lower this value

Solver Iteration Count <-- higher this one

this setting seem help but cost more processing power.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Box collider on Plane behaves like jelly 1 Answer

How can I show trajectory of a bouncing ball OnCollisionEnter/OnCollisionExit? 0 Answers

Need help with Raycasting 1 Answer

I have a sphere and a mesh (roulette table). Physics doesn't work. 2 Answers

Bouncing not working 1 Answer


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