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 /
This question was closed Apr 26, 2021 at 05:46 PM by Mariallam for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Mariallam · Apr 17, 2021 at 05:33 PM · collisionunity 2dcolliders

Ghost collisions problem: RigidBody player bounces, when moving on platform edges

Hi! I'm a beginner at Unity. In my first project I am trying to realize simple 2D runner game with mechanics of generating platforms one by one without distance between. The platforms are added by last position and reused, seems like all works fine. alt text Unfortunately, now I'm stuck with "ghost collisions" / "ghost vertices" problem. The player sometimes catches edges of platforms and bounces. So "IsGrounded" property becomes false and player can't jump. Platforms are located exactly next to each other.


I found the best visualization of this problem here (from 1:00). But I 'm not able to use tiles and composite colliders due to the fact that platforms should be generated randomly.


I can't find working solution on forums. I already tried:

  • to play with different types of colliders (edge collider for platforms, circle collider for player etc.).

  • to add edge radius to box and edge colliders,

  • to play with project settings of Physics and Physics 2D (Default Contact Offset, Default Solver Iterations, Default Solver Velocity Iterations etc.),

  • to change player Collision Detection to Continuous mode,

  • to play with materials friction,

  • to change Update event to FixedUpdate for player (made it worse).


I found this code, but it didn't help too.

 private void LateUpdate()
     {
         if (transform.hasChanged)
         {
             transform.hasChanged = false;
         }
         else if (rigidBody.velocity.magnitude == 0 && !isGrounded)
         {
             rigidBody.AddForce(Vector2.down);
         }
     }



Also platforms have "Ground" layer and ignore collision with themselves (Physics 2D > Layer Collision Matrix). I was surprised because it didn't help too. Why?


The situation has gotten better, but it keeps repeating sometimes. Maybe I used something wrong. Is there any way to avoid this annoying problem? :( Thanks.


Additional information about last project version:

Player has BoxCollider2D with 0.1 edge radius. Platforms have BoxCollider2D without edge radius. Player and platforms have 0 friction material. Player Collision Detection is in Continuous mode. Default Contact Offset is 0.0001. I use Update instead of FixedUpdate.

2021-04-17-17h47-46-2.png (35.1 kB)
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

  • Sort: 
avatar image
0
Best Answer

Answer by Mariallam · Apr 26, 2021 at 05:45 PM

The solution was to use adjacent Start / End points for platform EdgeCollider2D. Explanation: https://www.iforce2d.net/b2dtut/ghost-vertices

alt text


2021-04-26-20h24-26.png (16.7 kB)
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 eplaygame · Apr 17, 2021 at 11:20 PM

Two things come to mind:

  1. You use box collider - try to use sphere collider

  2. You can lift the current platform. Just try to create a simple script that lifts the platform when player is on for 0.01f or even less for instance. Yes, it is dirty fix, but may be it won’t be noticed if the value is tiny. OnTriggerEnter/OnTriggerExit can be used

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

Follow this Question

Answers Answers and Comments

185 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

Related Questions

How to optimize a lot of colliders? 1 Answer

PolygonCollider2d Use Z Axis 0 Answers

Destroy Clone Game Object On Collision Doesn't work 3 Answers

Colliding fast moving object with a slow moving object 1 Answer

How to detect if target is inside an "arc" area? 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