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 GRF75 · Jun 07, 2014 at 09:54 PM · collisionphysicsrigidbody

Change bounciness at runtime

A ball projectile is hitting bottles. Bottles move along a downward path using physics.

The projectile has a rigidbody with physic material in its sphere collider, with bounciness of 0. A bottle has a rigidbody with physic material in its collider, with bounciness of 0.

Bottles have different colors. Projectiles too. The idea is hitting bottles of the same color. No problem with the PhysX engine when projectile and bottle have the same color, it works as expected. The force of the projectile throws the bottle away. But when the projectile hits a bottle with different color, I want to the ball projectile to bounce; and the bottle to continue its way untouched.

Problems? A lot. - I tried to change the relative masses at OnCollisionEnter() expecting the bullet to rebound. Not working. - I tried to use Physics.IgnoreCollision(collision.collider, collider); at OnCollisionEnter(). Too late. - Changing the material for the bullet to make it bounciness.

I think what I need is to disable the physics for the bottle a bit before the collision, compare the colors and decide how to continue: - if same color, use physics. - if not, stop a bit the bottle physics, repel the projectile (how by the way?) and then continue the bottle physics.

Any idea? Anyone had a similar problem?

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
0

Answer by oasisunknown · Jun 07, 2014 at 10:44 PM

these objects sound like rigidbodies but with out your code its hard to give you any advice.

that being said here is what my guess would be.

Do a check when the ball enters the collider and check its color at that point verse that bottle just how you have been doing it.

if the colors match don't do anything because you said this part works already.

if the colors don't match then just give the ball an additional AddForce to give it a big push in the direction you want it to go.

I would not worry about how bouncy the object is. just give it an additional force and it will look like its bouncing away

but again if we can see your code we can give you more specific help.

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 GRF75 · Jun 07, 2014 at 11:02 PM 0
Share

Thanks, Oasis.

As I noted at the question, projectiles and bottles are rigidbodies. I need them to have real physics, except when hit and the color deter$$anonymous$$es what happens.

I've tried AddForce for the projectile at OnCollisionEnter(), that's O$$anonymous$$, no problem. Let's considered it solved.

But I can't keep the bottles from falling, when at OnCollisionEnter() it looks like it's too late to handle this. I tried changing masses, bounciness, Physics.IgnoreCollision. The bottle is already impacted.

Setting Is$$anonymous$$inematics = true for the bottle, stops the bottle from moving along a downward path using physics. I need this movement.

So, what I need is some way to avoid the collision for the bottle when colors are different.

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

22 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

Related Questions

Why is there no Rigidbody2D.SweepTest() ? 1 Answer

Handling colliders on hundreds of asteroids (not procedural asteroids) ...URGENT 3 Answers

physics culling mask? 1 Answer

Do you have to have a rigidbody component for collision detection? 1 Answer

Keep Horizontal Momentum after Jump 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