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 FarisGames · Jul 01, 2013 at 02:48 PM · javascriptrigidbodyraycast

How to stop a rigidbody from bouncing off when colliding

Hello,

i had a problem with my player rigidbody. when it collide with the wall it bounce off this might help to understand.

i'm searching for a way to stop the rigidbody when it reach a wall. i tried that with Raycast but i guess it's slower than the player impact speed. i want the player to just stop moving when it reach a wall. no bounce or walking through it.

My player is rigidbody controller by Add Force

Thanks

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by robertbu · Jul 01, 2013 at 05:47 PM

First walking through walls as a result of high velocity (assuming that is an issue for you) is a separate issue from bouncing off walls. There are hundreds of posts on going-through-walls issues. As for stopping, at the collision you can set the IsKematic flag of the rigidbody to true. Or as an alternate, you can set the velocity to Vector3.zero (but gravity will continue to pull the block down). Another way is to make the walls triggers, and set the IsKinematic flag on the trigger.

 function OnCollisionEnter(collision : Collision) {
      if (collision.collider.tag == "Wall")
          rigidbody.isKinematic = true;
  }

 

And if the walls are triggers:

 function OnTriggerEnter(collider : Collider) {
      if (collider.tag == "Wall")
          rigidbody.isKinematic = true;
  }

Note there is one frame of movement that occurs despite the code above. For most situations this is not a problem. But if it is, I worked out a couple of hacks:

http://answers.unity3d.com/questions/462907/how-do-i-stop-a-projectile-cold-when-colliding-wit.html

Comment
Add comment · Show 3 · 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 amphoterik · Jul 01, 2013 at 06:50 PM 0
Share

Couldn't a physics material also help here to remove the bounce?

avatar image robertbu · Jul 01, 2013 at 07:04 PM 0
Share

@amphoteik - yes if we are dealing with a simple collision between the wall and the object and if gravity is turned off. Removing the bounce does not stop movement based on other forces such as another rigidbody hitting the object or gravity pulling it down.

avatar image amphoterik · Jul 01, 2013 at 07:34 PM 0
Share

@robertbu that's what I thought. I guess I would need more info before knowing if it was a viable solution.

avatar image
0

Answer by absolutegames1 · Jul 01, 2013 at 07:33 PM

or maybe try to change the type of material, check if its bouncy(as material)

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 amphoterik · Jul 01, 2013 at 07:34 PM 0
Share

See my comment and @robertbu 's answer above.

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

17 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

Related Questions

Creating a teleportation gun 1 Answer

Need help with limiting rotation. 1 Answer

Trouble with RayCast, rigid body and the colliders tag 0 Answers

remove forward component from velocity vector 2 Answers

raycast to object, load wrong script!? 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