• 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
Question by Firox_ · Mar 07, 2020 at 06:36 PM · collisionmovementrigidbody2dphysics2d

Rigidbody2D doesn't move

I'm having an issue with the use of Rigidbody2D. I have a Rigidbody2D attached to my player and sometimes the player don't move even if it should. Here's a gif to show the problem.

alt text

Note that since the red square touch the ground I always press a key. One can see that the square is blocked for no reason at the limit of the first tile in the right. I don't ac$$anonymous$$eve to locate the problem source.

Here's the movement code:

 protected void Move(float x, bool jump)
     {
         Vector3 targetVelocity = new Vector3(x, rd.velocity.y);
         rd.velocity = Vector3.SmoothDamp(rd.velocity, targetVelocity, ref curVelocity, movementSmoot$$anonymous$$ng);
 
         if (jump)
         {
             t$$anonymous$$s.jump = false;
             if (onGround)
             {
                 rd.AddForce(new Vector2(0, jumpForce));
                 onGround = false;
             }
             else if (airJump)
                 rd.AddForce(new Vector2(0, jumpForce));
         }
     }

curVelocity is initialized to Vector3.zero and t$$anonymous$$s.jump is a property used to avoid some issues with update methods. There is a TilemapCollider2D attached to the tilemap of the w$$anonymous$$te squares. What can be the origin of the problem and how can I solve it please ?

Edit: I found the problem but I don't see how to solve it. I draw the contacts points of the Rigidbody2D and here is what I have: alt text For me it's non-sense. First I didn't thought that contact between Rigidbody2D and colliders occur when they are not against each other. Aside from t$$anonymous$$s, the 2 right contact points should not exist and I don't understand why the do.

2020-03-07-19-21-12-trim.gif (187.8 kB)
capture.png (38.4 kB)
Comment

People who like this

0 Show 0
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

3 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Marioooo · Mar 08, 2020 at 12:34 AM

Hi! why don't you use the "Box Radius" property on your Box Collider, t$$anonymous$$s way corers will no longer be a square and with a rounded corner, a tiny gap will not be a problem...

Hope t$$anonymous$$s Helps!

Comment
Firox_

People who like this

1 Show 0 · 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

Answer by Firox_ · Mar 08, 2020 at 10:07 AM

Thanks it solve my problem. But I still not understand why these colider points exists as there is no collider at their position. If you or anyone else have explaination for that I'll be glad to take it.

Comment
MUG806

People who like this

-1 Show 2 · 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 Mealey · Apr 04, 2020 at 04:49 AM 0
Share

Instead of doing that, what if we applied a very strong impulsive force to the bullet, much like the one in real life? Doing so will make the bullet move because of its momentum, and not because of a programmed position update My AARP Medicare

avatar image MatthewWJohnson · Sep 19, 2022 at 10:51 PM 0
Share

What I needed to hear, and you provided it, is thanks. Although I have a better idea of what they are, I still don't know why these colider points exist when there is no collider there (www myaarpmedicare com login). I would appreciate it if you or anybody else could clarify that to me.

avatar image

Answer by MUG806 · Sep 20, 2022 at 12:32 PM

Use a composite collider on your tile map. T$$anonymous$$s will combine the tiles into large surfaces, preventing the character getting stuck between tiles.

Comment

People who like this

0 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

239 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 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 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 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 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 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 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 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 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 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 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

How Do I Make a Rigidbody2d keep its force and move at a consistent speed? 2 Answers

2D Faux Gravity using a Point Effector? 1 Answer

Issues with Character Controller moving Enemies 1 Answer

Simplest way to deaccelerate a Rigidbody2D object 1 Answer

Reset Rigidbody2D rotation after collision 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