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
2
Question by Thomas · Nov 06, 2009 at 12:15 AM · collisionphysicsstick

Making a rigidbody stick to its position

When a collision with a collider happens, it's possible to detect velocity magnitude and trigger an event.

function OnCollisionEnter(collision : Collision) {  
    if (collision.relativeVelocity.magnitude > 2){
        ...
    }
}

How can I tell the attached rigidbody not to move when the magnitude is below that value?

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

4 Replies

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

Answer by runevision · Nov 06, 2009 at 09:28 AM

Rigidbodies are controlled by physics (unless they have the isKinematic flag). This means that the physics system will decide whether the Rigidbody will move or not.

If you want to have control yourself over when it moves or doesn't move, you have a few choices.

  • You can make the Rigidbody kinematic, and only turn isKinematic off when you want it to move. Since it will probably be kinematic in the moment of the collision, you may need to apply a force to the Rigidbody yourself to make it move.

  • You can have the Rigidbody be physics controlled all the time, but overwrite its position and velocity when it has moved and you didn't want it to. Just store variables with the position and velocity before the collision, and if the collision impact was not big enough, set the position and velocity after the collision to the stored values.

There may be other ways to do it, but those are the ones I could think of off the top of my head.

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

Answer by flaminghairball · Nov 08, 2009 at 08:54 PM

I guess you could also try manually setting the rigidbody velocity if the impact isn't strong enough, which at least works better in theory than manually setting position.

Just my two cents

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

Answer by $$anonymous$$ · Nov 08, 2009 at 09:35 PM

I'm not sure this will work, but you can try calling rigidbody.Sleep().

Alternatively, if you're just trying to control the level of bounciness, you can tweak the bounciness value in the physics materials.

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 AngryAnt ♦♦ · Nov 09, 2009 at 01:39 PM 2
Share

Calling rigidbody.Sleep () will allow the physics system to disregard the rigidbody for calculations until it becomes relevant again. However, you'll need to stop the rigidbody first by setting velocity to zero or the rigidbody will just jump straight back into action.

avatar image
0

Answer by kitt.du · Nov 17, 2009 at 12:01 AM

You could have a placeholder Trigger (Box Collider) which upon Collision would or would not initiate a Prefab object in it's place (perhaps the trigger Collider would be larger than your Prefab Object) depending on the magnitude of the collision.?? That might work.

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

No one has followed this question yet.

Related Questions

How to avoid objects bouncing and overlapping after collision? 0 Answers

RAYCAST KNOWLEDGE HELP!!! 1 Answer

How do I make make objects stick to a ball and affect (but not stop) its movement (like Katamari Damacy) 1 Answer

Collision position - Improving on the 'grounded' mechanic 2 Answers

Concave rotation Collision problem 3 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