Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Colliders not strong enough

Discussion in 'Editor & General Support' started by victeldo_unity, Nov 8, 2018.

  1. victeldo_unity

    victeldo_unity

    Joined:
    Sep 24, 2018
    Posts:
    24
    Hey guys,

    I have a fast rigidbody (Translates 150f per second) that easily goes through the colliders (But gets slowed down). Is there any way to make the colliders actually stop the rigidbody from going through? I've made the collision detection continuous, added the script from "http://wiki.unity3d.com/index.php?title=DontGoThroughThings" and added an extra collider on the rigidbody character but it still manages to go through the border colliders of the map with ease! Is there anything I can do to make the collider force stronger?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    4,905
    At that speed you should probably use ray casting instead.
     
    leftshoe18 likes this.
  3. Gambit-MSplitz

    Gambit-MSplitz

    Joined:
    May 16, 2015
    Posts:
    1,117
    Rigidbodies have a "SweepTest" function that allows you to pass in a vector for movement, and it will return information that allows you to determine if there was a collision, and where to stop your Rigidbody so that it doesn't overlap or go through what it collided with.

    I'm not sure how to make this play nicely with Rigidbody.velocity if you are using forces. If you are going to use a sweep test, you probably want to do it in a FixedUpdate.

    https://docs.unity3d.com/ScriptReference/Rigidbody.SweepTest.html


    If you're using 2D colliders, you will want to use Collider2D.Cast() instead of Rigidbody.SweepTest().

    https://docs.unity3d.com/ScriptReference/Collider2D.Cast.html