# \[RELEASED\] Physics Debug Extension

**URL:** https://discussions.unity.com/t/released-physics-debug-extension/669913
**Category:** Community Showcases
**Tags:** Asset-Store-Assets
**Created:** [July 5, 2017, 1:08am UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913 "2017-07-05T01:08:39Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [July 5, 2017, 1:08am UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/1 "2017-07-05T01:08:39Z")

</div>

**Physics Debug Extension**

 ![3133165--599143--CoverImage_1950x1300_FINAL.jpg](https://europe1.discourse-cdn.com/unity/original/4X/6/1/3/6135c27d423719f0f094ed4383edd717c15e3e71.jpeg)

**Website:** [**RotaryHeart.com**](https://www.rotaryheart.com/)  
**Product Wiki:** **[Online](https://www.rotaryheart.com/Wiki/PhysicsDebug.html)**

**Version 2.0.0**  
Available Now: [**Asset Store**](https://assetstore.unity.com/packages/tools/physics/physics-debug-extension-88947)  
[**Release Notes**](https://discussions.unity.com/t/released-physics-debug-extension/669913/48)

Physics Debug Extension is a system that allows to preview any Physics cast, checks or overlaps. It can easily be used without much code modification.

A code that normally uses:

```csharp
Physics.SphereCast(bottom, top, transform.forward, out hit, 10)

```

Will only need to be changed to

```csharp
RotaryHeart.Lib.PhysicsExtension.Physics.SphereCast(bottom, top, transform.forward, out hit, 10, RotaryHeart.Lib.PhysicsExtension.Physics.PreviewCondition.Editor)

```

Note that the last parameter will indicate if the lines should be previewed at editor, game or not drawn at all.

It even have 2 extra parameters to change the hit and no hit color, which are optional. Here’s a quick preview of how it looks:

 ![3133165--237413--Preview.png](https://europe1.discourse-cdn.com/unity/original/4X/c/f/9/cf9e70078cb0567a8030cee35b5bd13f10bd2f74.png)

Here you can see a Sphere cast from the camera, a line cast from the character face and 3 box cast (object left, right, up direction)

It even shows the collision point like this:

 ![3133165--237415--Preview2.png](https://europe1.discourse-cdn.com/unity/original/3X/d/e/de9253c6bcad6582f319224db7a12257587bd65e.png)

After a couple of requests for in game preview I was able to implement it using [Unity GL](https://docs.unity3d.com/ScriptReference/GL.html). So now you can see all the lines on a game too.

If none is passed as preview parameter then it will work the same way as the Unity physics cast since all the drawing is by passed. Currently all the Unity casts, checks and overlaps are implemented.

Currently tested systems:  
Windows  
Android  
Mac  
Linux  
iOS

 ![3133165--599146--Screenshot_2048x1152_ Easy to view lines.jpg](https://europe1.discourse-cdn.com/unity/original/4X/7/3/1/731220235d671a979c799b4d16094e5cb154b6a4.jpeg)  
 ![3133165--599149--Screenshot_2048x1152_Able to preview on game window without gizmos Clear.jpg](https://europe1.discourse-cdn.com/unity/original/3X/8/0/80c554f59f99e5403c2caaf36ef0dbc4e2943f28.jpeg)

---

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [December 10, 2017, 5:18am UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/2 "2017-12-10T05:18:35Z")

</div>

Version 1.0 has been submitted to the asset store for review. This is the first public released. Anyone that got the package from email should download this one.

---

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [January 6, 2018, 5:33am UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/3 "2018-01-06T05:33:45Z")

</div>

I have no idea why the Asset Store has been taking so long to publish the asset, but if anyone is interested feel free to pm me and I will provide the package.

---

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [January 11, 2018, 8:22pm UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/4 "2018-01-11T20:22:40Z")

</div>

Good news, the asset is live now.

---

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [February 10, 2018, 10:03am UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/5 "2018-02-10T10:03:34Z")

</div>

Version 1.2 has been submitted. This includes a couple of bug fixes:

- Changed preview behavior for single casts (line, sphere, capsule, and box) so that it reflects exactly how the Physics check works.
- Changed collision preview behavior for cast all (box, capsule) to draw the respective figure since it only worked correctly for forward direction.
- Cleaned up the code a little

---

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [February 21, 2018, 10:10am UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/6 "2018-02-21T10:10:45Z")

</div>

Product wiki page has been completed. It can be accessed on the [Wiki](https://www.rotaryheart.com/Wiki/PhysicsDebug.html) section of our web page.

---

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [May 3, 2018, 9:13pm UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/7 "2018-05-03T21:13:40Z")

</div>

Version 1.2.1 been submitted to the asset store for review. This version includes:

- New folder structure.
- Updated documentation.

---

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [May 4, 2018, 5:41pm UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/8 "2018-05-04T17:41:52Z")

</div>

Version 1.2.1 is now live on the asset store!

---

<div class="post-metadata">

### Author: ![LemurusBalok](https://avatars.discourse-cdn.com/v4/letter/l/ce73a5/32.png) [@LemurusBalok](https://discussions.unity.com/u/LemurusBalok)
#### Post date: [September 21, 2018, 6:17am UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/9 "2018-09-21T06:17:12Z")

</div>

Hey! The Gl Lines are drawn in the game view in Unity Editor, but does not work in Android Builds? Is this due to the shades being used?

---

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [September 21, 2018, 7:07am UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/10 "2018-09-21T07:07:19Z")

</div>

> [@LemurusBalok](#):
>
> Hey! The Gl Lines are drawn in the game view in Unity Editor, but does not work in Android Builds? Is this due to the shades being used?

Hello,

It seems like Unity is not including the shaders when the game is compiled. So go to _Project Settings \> Graphics_ and on the section that says “_Always Include Shaders_” include the shaders GLlineZOff and GLlineZOn

![3703348--305749--upload_2018-9-21_3-3-30.png](https://europe1.discourse-cdn.com/unity/original/4X/c/2/0/c203eb9b0270640815a7d1544deecea9a55d6e05.png)

Then try compiling again, if when compiling you get an error that those shaders are hidden. The error will start like this:

> [@](#):
>
> An asset is marked with HideFlags.DontSave but is included in the build:

Open both shaders add an empty line at the end and save them. (This is the only way I have found to be able to not make them hidden by Unity) That will allow you to have it working for android, here’s a screenshot of the example scene working on Nox.

![3703348--305746--upload_2018-9-21_3-3-12.png](https://europe1.discourse-cdn.com/unity/original/4X/7/9/a/79ab417999dd254d1ca55a1497a562ebd4ac7d85.png)

---

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [September 22, 2018, 12:13pm UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/11 "2018-09-22T12:13:44Z")

</div>

Version 1.3 been submitted to the asset store for review. This version includes:

- New folder structure.
- Updated documentation. (Explains how to resolve the issue above)
- Modified GLDebug script to have shader fields that can be used to force Unity to include the shaders. This only works if the component is manually added to the camera.

---

<div class="post-metadata">

### Author: ![LemurusBalok](https://avatars.discourse-cdn.com/v4/letter/l/ce73a5/32.png) [@LemurusBalok](https://discussions.unity.com/u/LemurusBalok)
#### Post date: [September 25, 2018, 10:28am UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/12 "2018-09-25T10:28:06Z")

</div>

@Rotary-Heart Thanks! I fixed it by putting the shaders in the Resources folder and loading them with Resources.load in the GlDebug File.

---

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [September 25, 2018, 11:40am UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/13 "2018-09-25T11:40:43Z")

</div>

Version 1.3 is now live on the asset store!

@LemurusBalok Good to know that you were able to resolve it.

---

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [October 10, 2018, 9:28pm UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/14 "2018-10-10T21:28:33Z")

</div>

Version 1.3.1 been submitted to the asset store for review. This version includes:

- Fixed bug where lines for Sphere and Capsule casts where forced to be drawn on editor only.

---

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [October 12, 2018, 5:30pm UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/15 "2018-10-12T17:30:58Z")

</div>

Version 1.3.1 is now live on the asset store!

---

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [May 24, 2019, 11:54pm UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/16 "2019-05-24T23:54:47Z")

</div>

Version 1.4 has been submitted to the asset store for review. This version includes:

- All 2D physics casts and checks

---

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [May 27, 2019, 12:41pm UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/17 "2019-05-27T12:41:50Z")

</div>

Version 1.4 is now live on the asset store!

---

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [February 27, 2020, 4:02am UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/18 "2020-02-27T04:02:25Z")

</div>

Version 1.5 has been submitted to the asset store for review. This version includes:

- Added option to see lines on both the game and editor window at the same time.
- Multiple tweaks to the code for performance and small fixes.

---

<div class="post-metadata">

### Author: ![Rotary-Heart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/rotary-heart/32/293860_2.png) [@Rotary-Heart](https://discussions.unity.com/u/Rotary-Heart)
#### Post date: [February 27, 2020, 6:52pm UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/19 "2020-02-27T18:52:06Z")

</div>

Version 1.5 is now live on the asset store!

---

<div class="post-metadata">

### Author: ![Gooren](https://avatars.discourse-cdn.com/v4/letter/g/b5a626/32.png) [@Gooren](https://discussions.unity.com/u/Gooren)
#### Post date: [July 5, 2020, 7:18am UTC](https://discussions.unity.com/t/released-physics-debug-extension/669913/20 "2020-07-05T07:18:58Z")

</div>

The awesomeness of this tool is amazing!!!  
Thank you for sharing it with the community.  
It helped me debug sphere and specially capsule casts with such incredible ease… oh boiiiiiiiiiii!!!

Two minor things:

- HDRP in-game gizmo rendering doesn’t work, but we don’t much need it anyway
- We have to use PhysicsExtension check/cast methods only temporarily while we debug, since the internal evaluation boils down to ‘ray.direction.Normalize();’. This leads to performance degradation ☹ We never call it with non-normalized direction anyway. And we don’t even use Ray ourselves, always call the ‘origin’, ‘direction’ overloads.

[Next page](https://discussions.unity.com/t/released-physics-debug-extension/669913.md?page=2)
