Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    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:
    3,811
    At that speed you should probably use ray casting instead.
     
    leftshoe18 likes this.
  3. Gambit-MSplitz

    Gambit-MSplitz

    Joined:
    May 16, 2015
    Posts:
    970
    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