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 The-Gabo · Aug 30, 2013 at 08:16 PM · colliderstopsticky

sticky and blocking colliders that stop my character from running around.

Hi, everybody !

In the many plaformers that i've tried to devellop, there is a problem with the collider walls my rigidbody player (he is not a character controller) walks in. When touching a collider , my player cannot jump, he stays blocked near this collider until you release the move arrows, or the jump key. I would be more specific, but my problem couldn't be fixed with a code i think. Maybe there's a Rigidbody variable I mistreated.

Thanks for reading !

Comment
Add comment · Show 3
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 robertbu · Aug 30, 2013 at 11:23 PM 0
Share

Did you add a Physic material to the colliders? You can get sample Physic materials by Assets>Import Package>Physic $$anonymous$$aterials. Start with something slippery like 'Ice'. You can create your own materials with the properties you need.

avatar image meat5000 ♦ · Aug 30, 2013 at 11:53 PM 0
Share

There is a 'Frictionless' Physic material in AngryBots tutorial.

avatar image The-Gabo · Aug 31, 2013 at 10:45 AM 0
Share

Alright thanks i'll chek it out. Didn't know much about physics materials.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by donnysobonny · Aug 31, 2013 at 01:05 PM

I have had this problem numerous times also within project developed inside of Unity. The problem is not due to the physics material, it is because when you are holding the arrow button, the engine is physically trying to push your object through the wall and the physics engine is trying to correct it by pushing it back away from the wall at the same time. This ultimately leads to the problem that you've described and is something that really should be avoided using a collision detection system.

The easiest and most optimised way to do this would be to cast a ver short ray directly infront and behind of your character. If the ray infront collides with something, disable forward movement, if the ray behind collides with something, disable backwards movement.

You could even take this one step further and use the above method to trigger animations to simulate bumping into a collider.

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 The-Gabo · Aug 31, 2013 at 01:50 PM 0
Share

Actually thanks to the friction less material. $$anonymous$$y character is much more " slippery i guess. It sorted a lot of things and it's now much more playable.

avatar image
0

Answer by acornies · Jun 04, 2014 at 03:44 PM

I solved this "sticky" ridgidbody issue using the solution suggested by @donnysobonny.

The easiest and most optimised way to do this would be to cast a ver short ray directly infront and behind of your character.

Here's some code that I put in FixedUpdate() to solve it. Keep in mind that my game is 2.5D using the Unity 2D view on the x and y axis.

 rigidbody.velocity = new Vector2(
     this.MoveDirection * this.MaxSpeed, rigidbody.velocity.y);
 
 RaycastHit hit;
 if (Physics.Raycast(transform.position, Vector3.right, out hit, 0.1f)
     || Physics.Raycast(transform.position, Vector3.left, out hit, 0.1f)) {
         Debug.Log("Hit " + hit.transform.gameObject.name);
         if (hit.transform.tag == "Stoppable"){
             rigidbody.velocity = new Vector2(0, rigidbody.velocity.y);
         }
 }

In this example, I've tagged the objects I'm colliding with using a custom "Stoppable" tag. This can easily be changed to hit.transform.name, layer or some other identifier. I'm also using my own "MaxSpeed" and "MoveDirection" variables to handle the initial ridgidbody velocity.

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 RigOrd · Nov 17, 2016 at 12:33 PM 0
Share

Hello there. I am new to unity, can you $$anonymous$$ch me how to do it? Can you email me? fajardo.timothy@gmail.com

this is my last bug in my game for our thesis, I hope you can help me. Thank you in advance

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

21 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

Related Questions

Need help when arrow hits collider 1 Answer

2 cubes go through each other instead of stopping 0 Answers

Internal collisions 1 Answer

Wheel Collider General Friction 1 Answer

how to stop/suspend all motion after collision 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