Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Player Goes inside 'Platform with Box Collider' if velocity high enough

Discussion in '2D' started by iamfeyre, Feb 12, 2018.

  1. iamfeyre

    iamfeyre

    Joined:
    May 20, 2016
    Posts:
    56
    So The Problem is that i have a platformer in which the player dashes some distance.. But, if i dash close to a higher platform or into a wall or steps.. sometimes my player goes 'Inside' it breaking through the Box Collider. How do i fix that?? Here's an example - (Normal and inside Platform Pics)



     
  2. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    1,243
    Can you paste pictures of your RigidBody settings (for both - character and platform)?
     
  3. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    899
    Are you using FixedUpdate() for your physics updates? Have you tried setting Collision Detection to Continous in your Rigidbody?
     
    SolidNecros likes this.
  4. iamfeyre

    iamfeyre

    Joined:
    May 20, 2016
    Posts:
    56
    I Didn't Want to use Continuous cause i read that it degrades performance a lot

    Here they are !! (They are all Unity default.. i didn't change anything)



     
  5. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    899
    That is certainly true. But for a single object, such as your player, it shouldn't make a difference. It is well worth trying out to see if it fixes your problem.

    Are you moving your player via AddForce or .veclocity?
     
  6. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    1,243
    That's the problem. As @PGJ said, swich collision detection to continuous.


    Well, let's take a philosophical perspective.
    "Degrades performance" compared to what? Falling through the floor. :D
    And don't prematurely ejacu-... optimize.
     
  7. iamfeyre

    iamfeyre

    Joined:
    May 20, 2016
    Posts:
    56
    im moving player with velocity but Dashing is with AddForce

    So do i need to change collision detection to continuous for Only Player or Platforms too??

    I Also read to decrease fixedUpdate time to 0.005 or something.. i know it degrades performance even further.. but just for the sake of it i tried it... but then i could'nt jump... my jump functionality fails an di have to put it back to 0.02... why is that ?!!

    PS - the jump is working.. but the force is like lessened.. like in 0.02 800 force upward is equal to 3000 in 0.005 why is that?!!
     
  8. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    1,243
    I don't know exactly how collision detection is calculated in Unity but logically, since player is the force exerting entity in this case, I would assume that just having continuous collision detection on player is enough.
     
  9. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    899
    It should be enought with continous on the player.

    Are you doing a GetButtonDown (or similar) in FixedUpdate()? Those don't work there, they only work in Update(). Putting them into FixedUpdate() will result in missed button presses.
     
  10. iamfeyre

    iamfeyre

    Joined:
    May 20, 2016
    Posts:
    56
    GetButtonDown is in update...

    But ground check is in fixedupdate...
    could that be the issue??