Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Sici9 · Nov 08, 2018 at 04:51 PM · rigidbody2dtopdownkinematic2.5drigidbody-collision

Blocking a kinematic rigid body2D through collision with static and/or other kinematic object?

Hi everybody,

This is my first time asking a question here, hope to make it right! So I have been using Unity 2017 for some time and I was trying to create a 2D topdown game. I am having some issues with the collisions: basically I created my player as a 2D kinematic object with a capsule collider 2D and then tried to block its movement trough collisions with some wall, which I created as a 2D static object with an edge collider 2D. Since from what I understood a kinematic body should not be able to interact straightforwardly with other kinematic or static objects, I went to Edti>Project Settings>Physics and enabled kinematic static pairs, as well as ticking Use full kinematic Contact. But still, my player goes through walls and everything. I thought it was a layer problems, so I double checked the interaction matrix, but it was ok, same for the Z-position. As last thing I tried to debug trying to print something using OnCollisionEnter2D, and it actually detected the collision! So finally the question: is there a way to make such that a static rigidbody2D is able to block the movement of my kinematic rigidbody?

PS: Before using the edge collider2D, i tried as well with polygon and box collider, with the same results. I have also tried to set the walls as dynamic and clamping all their movement, but the result was that the player simply carried around the walls as if it was nothing LOL (i think it is due to the fact that a kinematic rigidbody is assumed to have infinite mass when colliding with a dynamic one).

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 hectorux · Nov 08, 2018 at 10:49 PM

What function are you using for move? Translate is a teleport and will make it pass through colliders, if you want to move a rigidbody try MovePosition in the rigidbody component

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 Sici9 · Nov 08, 2018 at 10:55 PM

I am actually calling it already in the fixed update:

 private void FixedUpdate()
             {
                 myRigidBody.MovePosition(myRigidBody.position + moveVelocity * Time.fixedDeltaTime);
             }
     

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 hectorux · Nov 08, 2018 at 11:06 PM 0
Share

Try to constrain all the axis, and set it to unkinematic, if this doesnt work sorry:¨(

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

97 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

Related Questions

How to get acceleration in a top-down angle 0 Answers

Spin a non-kinematic 2d object ? 0 Answers

Why doesn't Rigidbody.velocity.x = 0 in a collision? 1 Answer

I need help with rigidbody and collision or something idk 2 Answers

2D Colliders stops working at random despite rigidbody, OnMouseDown not called 0 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