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
1
Question by Berenger · Jan 15, 2012 at 02:32 AM · physicsbounceenergy

Bouncing objects and Energy loss

Hi

Is there a way to have a bunch of objects, let's say balls, randomly launched in a closed area, bouncing forever with a constant speed? (I am trying to achieve that)

Everything in the scene has the same physic material, with no friction and bounciness = 1.The balls don't have any drags.

I've noticed two things. First, when two balls collide, they cancel eachother's energy when I want them to bounce and keep the same speed. Secondly, When the direction of a ball is almost parallel to the wall it's heading for, the ball will stick to the wall forever.

Is there a way to get that behaviour only by a proper set up of the physic ? If it have to be by a trick in a script, so be it, but it seems dirty ...

Comment
Add comment · Show 1
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 · Jan 15, 2012 at 04:19 AM 0
Share

If it's only in 2 dimensions, you could write your own physics engine. It's much easier to make a stable physics system in 2 dimensions than it is in 3, and you won't have to do all that clamping business.

2 Replies

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

Answer by Berenger · Jan 15, 2012 at 05:31 AM

Problem solved, kinda. For those interested :

I am doing a mix of physic for collision detection, and simple movement (pos = pos + dir * speed, when collission you do dir = Vector3.Reflect( dir, normal ) and it's ok )

The tricky parts :
Collide with the walls. The balls are kinematic, so the collision with walls is raised only if a non-kinematic rigidbody is awaken by the kinematic ball. Easy, give the walls a rigidbody with all constrains frozen.

Collide with other balls. Sweet Jesus, all the balls are kinematic, they won't raise OnCollisionEnter event between each others ! Don't panic. Create an empty gameObject child of the ball, with a rigidbody (no gravity, no drag, not kinematic), a sphere collider, then set one layer for the ball and a different one for the child. Edit->ProjectSettings-Physic, make sure the ball layer don't collide with the child one. Then create a script for the child which send a message upwards when a collision occurs. Done :)

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 lijrobert · Jan 15, 2012 at 03:47 PM 0
Share

I knew there was a way to do it with out animation, this may help me later on I'm doing a game with allot of traps #potential

avatar image
0

Answer by lijrobert · Jan 15, 2012 at 02:58 AM

The only way I can think of doing some of the things your saying is by animating the balls, but there may be any easier way. Maybe with the wall problem you could make the wall a trigger and it activate a animation that makes the ball drop.

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 Berenger · Jan 15, 2012 at 03:50 AM 0
Share

I'm in 2 dimensions (camera ortho, no gravity, every rigid body frozen on one axe etc). An animation is not really going well with the random aspect I'm looking for. Plus the player can add walls anywhere.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Bouncing Ball and Walls 1 Answer

Cant find options to change physic material to bouncy 2 Answers

How to make an infinite mass solid body 1 Answer

Reducing bounce on simple boxes 0 Answers

Can't set Bounce Threshold below .3 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