Search Unity

Super Raycast - Perfect collision detection against Renderers without colliders.

Discussion in 'Assets and Asset Store' started by neon_teebar, Jun 1, 2017.

  1. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46

    Features
    • High precision.
    • No collision mesh & no set up needed.
    • SkinnedMeshRenderer (animation) support.
    • Optional Bump Map support for a higher quality collision normal.
    • Optional Height Map support for a higher quality collision point.

    Implementation note
    SuperRaycast is 400x slower than the built in Unity Physics.Raycast but still fast enough to cast multiple rays against 1000s of objects every Update, even in VR.

    If it is slow for you it may be the method you are using. Below are methods available ranked by speed.

    1) Fastest: Maintain an array of Renderers, and call SuperRaycast.Raycast(Ray ray, Renderer[] targets, out RaycastHitInfo hitInfo);

    2) Fast: Give each object a box collider and call SuperRaycast.PhysicsRaycast, which will use the fast Unity raycast to detect for objects, then it will use SuperRaycast to only test against those objects. It calls transform.GetComponentsInChildren<Renderer>() which is slow, but caches the results, so gets faster.

    3) Medium: SuperRaycast.Raycast(Ray ray, GameObject target, out RaycastHitInfo hitInfo). This will only test against Renderers of this objects children, rather than all Renderers in the scene.

    4) Slowest: SuperRaycast.Raycast(Ray ray, out RaycastHitInfo hitInfo). This calls GameObject.FindObjectsOfType<Renderer>() which is slow if there are a lot of objects.

    I'm planning on adding an octree system eventually, which should be faster than all the above methods.




     
    Last edited: Feb 24, 2018
    Gekigengar and iconnary like this.
  2. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    This could using for mobile platforms ? And any have a demo for this ?
     
  3. FDT

    FDT

    Joined:
    Aug 17, 2014
    Posts:
    11
    I can confirm that as today, the example has errors in mobile. Deleting the multiple objects example and adding the raycast shader to the preloaded assets have make it work in android,

    I tried it in a UMI Z PRO and it doesn't work (it detects collision with the skinned mesh renderer but it can't give the exact ray position), and it's too slow in a ZTE BLADE L3.

    I hope this helps to move it forward, because it's a very needed feature.
     
  4. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    Thanks for the info FDT, I will try to get around to creating a mobile optimized version eventually.

    I've submitted v 1.1, which should fix the issues in the multiple objects example. In the new version toggle SuperRaycast.OPENGL = false.

    Among other things normal map testing now takes into account the materials normal map scale and I added heighmap support. (Notice the bobbing while cast against a flat plain.)
     
    Last edited: Jul 13, 2017
  5. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    306
    Hello, this seems to be a very useful tool, how does it works tho? Somebody mentioned something about a raycast shader, will I need to use this shader in the objects I need to hit tests? I have many objects with custom shaders, does this means I will lose the ability to use my own shaders?

    What is the performance overheat of this tool?

    Thank you in advance for your response, Im looking forward using this tool!
     
  6. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    You don't have to set anything up. Leave all your shaders and materials the way they are. Just call SuperRaycast.Raycast the way you would Physics.Raycast.
    The only difference is this will test against renderers, instead of physics meshes.

    You can see in the demo video I have like 7 rays casting against an object and am running over >60fps. But I have a decent PC. I'm not sure how well it works on mobile, though there are things I might be able to do to optimize for mobile.

    There are two techniques used, one for testing against a single Renderer (MeshRenderer, SkinnedMeshRenderer...) and one for testing against multiple Renderers. The multi renderer Raycasting might be a bit slower. I tested it against 10,000 items at once and it ran at 20-30 fps.
     
  7. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    306
    Thanks for your answer, so do you think there wont be any performance overheat when testing hits agains 30k verts meshes?
     
  8. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    The complexity of the mesh shouldn't matter much.
    Basically, the objects are drawn to a 2x2 rendertexture. So if your 30k mesh can render to a 1024x760 at runtime speed, rendering to 2x2 should be pretty fast.

    After rendering the objects, the biggest bottleneck is reading the RenderTexture. I hope to some day find a faster way to read RenderTexture data. Maybe I have to look at ComputeShaders.

    I did a quick stress test comparing it to the Physics.Raycast, but these speeds could be pretty different depending on the gfx card.
    100x
    Physics Raycast: 0.000495195388793945 ms
    Super Raycast: 0.0637741088867188 ms
    Physics is 0.0632789134979248 ms faster.

    1000x
    Physics Raycast: 0.000739097595214844 ms
    Super Raycast: 0.493463039398193 ms
    Physics is 0.492723941802979 ms faster.

    10,000x
    Physics Raycast: 0.00943613052368164 ms
    Super Raycast: 4.86244487762451 ms
    Physics is 4.85300874710083 ms faster.
     
    Fibonaccov and Gekigengar like this.
  9. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    306
    This is awesome work! I will totally try your asset. Thanks a lot for the analysis
     
  10. macdude2

    macdude2

    Joined:
    Sep 22, 2010
    Posts:
    686
    I'm really curious for more information about how it works? Are you doing a texture based raycast? I don't see how the 2x2 texture would help that much? Wait, are you doing a depth map or something? So you just need the depth of the pixels?

    If you could write all the pixels from the individual recasts to one texture, (to then use a compute shader with) I'm sure that would speed things up a fair bit. Though I'm not sure how feasible it would be to assemble multiple camera feeds without the cpu.
     
    Last edited: Jul 17, 2017
  11. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    Yeah you're on the right track. Though it doesn't use multiple camera feeds. I only call camera.Render once per cast.

    Reading the RenderTexture takes pretty much %50 of operation time, so a compute shader could really speed things up, unfortunately they don't work for me in the Linux Editor, even though I have OpenGL 4.1, so I have no way of testing atm.
     
  12. Fairennuff

    Fairennuff

    Joined:
    Aug 19, 2016
    Posts:
    88
    Hello There!

    Just got your asset and was tinkering with it. Any chance to add layermask as an overload? Also a distance limiter like a normal raycast has?
    Thanks!

    Edit: Also after some testing I can't seem to get this to hit standard Mesh Renderers. Only Skinned and Terrains. At least doing a simple RayCastHitRenderer.renderer.name always returns null unless its a skinned mesh.
     
    Last edited: Aug 8, 2017
  13. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    Sure I will add a layermask and max distance option for the next update.

    Do you mind showing how you called Raycast so I have a general idea where the problem might be? Thanks.
     
  14. Fairennuff

    Fairennuff

    Joined:
    Aug 19, 2016
    Posts:
    88
    Ray grabRay = new Ray(transform.position, Vector3.down);
    RaycastHit hit;
    RaycastHitRenderer hitRend;
    if (SuperRaycast.Raycast(grabRay, out hitRend, out hit))

    This is for a VR game. I'm raycasting a short distance from the hand, directly down to determine if there is a ledge or climbable object below it to grab onto. If I can get this to work I wont need mesh colliders for everything and that'd be awesome!
     
  15. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    I think I found/solved the issue and uploaded it. It shouldn't take long before the Asset Store approves it.
    Max distance, and layer mask filtering are also available now.
     
  16. Fairennuff

    Fairennuff

    Joined:
    Aug 19, 2016
    Posts:
    88
    Haven't seen an update on the store. Any idea on an ETA?

    Thanks
     
  17. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    I'll DM it to you. Usually updates take a day or two. 7 at most, i think.
     
  18. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    306
    Hello

    I just got this asset, looks very good. I have a question tho.
    I see that in the SkinnedMeshDemo you have to set a target mesh to the hit test. How can I do it if my ray should test different meshes, example a character and its accessories?

    Thanks for your help
     
  19. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    306
    Another problem, Im getting this error when trying to build:
    Player export failed. Reason: Shader error in 'Teebar/Physics/Super Raycast': Failed to find parameters of a compiled D3D9 shader (on d3d9)
     
  20. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    Hey thanks for the info. That "Failed to find paramaters..." error was solved in 2017.1.05p https://unity3d.com/unity/qa/patch-releases/2017.1.0p5
    It only occurs in some versions of Unity.
    I think it's because they are removing directx 9 support.

    For the other question, there are a number of methods that can be called like:

    SuperRaycast.PhysicsRaycast(ray): which will cast a ray with Unity's ray caster, then it will test against the Renderers of the hit objects. So you might add a box collider to your object, so it can be detected by the Unity raycast, and then if contact was made SuperRaycast will run a better test on it.

    or

    SuperRaycast.Raycast(ray, Renderers[]): which will test against an array of Renderers. So for instance when an enemy is spawned you could do
    Code (CSharp):
    1. public Renderer[] enemyRenderers = new Renderer[0];
    Code (CSharp):
    1. void OnEnemySpawn(){
    2.     ArrayUtility.AddRange(ref enemyRenderers,
    3.     enemy.GetComponentsInChildren<SkinnedMeshRenderer>());
    4. }
    or

    SuperRaycast.Raycast(ray, GameObject): which will test against all the Renderers in a GameObject.
     
    Fibonaccov likes this.
  21. Diego-de-Paula

    Diego-de-Paula

    Joined:
    Oct 10, 2012
    Posts:
    2
    Hello, I just bought your asset and been trying to use it for my purposes. I'm making an F-zero style game and Super raycaster allows me to orient my ship according to the shader smooth normal instead of the hard edged collider normal. This is exactly what I wanted so my ship orients itself smoothly across the loops and curves of the track, without having to use a super dense mesh.

    The only question I have has to do with the RaycastHitRenderer.point
    The normal of the Hit is given according to the smoothed shader normal, but the point of the hit is still based on the actual flat geometry, similar to how the standard raycast works on colliders.
    Is there a way or functionality I'm missing that can give me the perceived height of the imaginary point the ray hits according to the smooth shading?

    That way I can not only orient my ship to the track surface but also position it in the correct height in that surface so that when the ship goes up a ramp or loop, it transitions it's height smoothly instead of jerking up when it goes over the next face.

    PS: I'm not using any kind of bump maps, normals maps or height maps. I'm only using a mesh that has it's faces set to smooth shading.
     
  22. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    I don't know if shaders are capable of estimating a smoothed point between vertices, which is why height maps were invented.

    I'm assuming you want to accomplish this bobbing effect?

    That is a flat cube with only 8 vertices, but it reads the _ParallaxMap (Height Map) to calculate the perceived height.

    To use that feature you'd set USE_HEIGHTMAPS = true and then it will look for a _ParallaxMap if it's available in the material of the hit object(s).

    Your materials don't have to actually use the _ParallaxMap in their own rendering. Simply add:
    Code (CSharp):
    1. _ParallaxMap ("Height Map", 2D) = "white" {}
    to the Properites section of your shader and
    Code (CSharp):
    1. sampler2D _ParallaxMap;
    in the Pass section will let you give materials a height map, which can be read by SuperRaycast.

    But I could modify the system to make it easier for your setup.

    Another technique might be to just smooth the point:
    Code (CSharp):
    1. hitPoint = Mathf.Lerp(hitPoint, hitInfo.point, .25f);
     
  23. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    Does this work on the editor with scene view camera rays? Was thinking of grabbing this for use in an editor placement tool instead of the more complicated current octree solution.
     
  24. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    It used to work perfectly in editor, but in the newer versions of Unity it works intermittently, and I haven't been able to figure out why that is.

    It will work one frame, and then not the second, and then a frame or two later it will work again. It's mind boggling, but I'll figure it out some day.
     
  25. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    I need to do raycasts against geometry that's being displaced by a vertex shader. Unfortunately there is no heightmap, it's generated in the shader with 3d noise. Can Super Raycast help me?
     
  26. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    If you know your way around shader code, you could modify the vertex function on SuperRaycast.shader, shown below.

    Code (CSharp):
    1. v2f vert(appdata v, out float4 outpos : SV_POSITION)
    2. {
    3.     v2f o;
    4.     o.normal = v.normal;
    5.     o.tangent = v.tangent;
    6.     o.color = v.color;
    7.  
    8.     o.texcoord0 = v.texcoord0;
    9.     o.texcoord1 = v.texcoord1;
    10.     o.worldPos = mul(unity_ObjectToWorld, v.vertex);
    11.  
    12.     outpos = UnityObjectToClipPos(v.vertex);
    13.  
    14.     return o;
    15. }
    Code (CSharp):
    1.  
    2. // So you'd probably want to change this...
    3. o.worldPos = mul(unity_ObjectToWorld, v.vertex);
    4. outpos = UnityObjectToClipPos(v.vertex);
    5.  
    6. // to this...
    7. float4 vertModified = v.vertex + yourNoiseOffsetFunction();
    8. o.worldPos = mul(unity_ObjectToWorld, vertModified);
    9. outpos = UnityObjectToClipPos(vertModified);
    10.  
     
    Fibonaccov and brisingre like this.
  27. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    277
    That seems pretty doable.
     
  28. Festina_Lente

    Festina_Lente

    Joined:
    Nov 9, 2017
    Posts:
    14
    Hi neon_teebar, your asset looks like a great product. I bought it today, installed it under Unity 2017.1.2 and I have problem when scene contains the second camera which overlays the main camera at the top-right corner. To reproduce this error, place the second camera (X:0.8 / Y:0.8 / W: 0.2 / H:0.2 / secondCamera.depth > mainCamera.depth) into your MultiRenderer Demo and the black cursor will be flickering and changing orientation. Only when the second camera is at bottom-left corner it works as expected. Thank you in advance for your response.
     
  29. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    I've been trying to reproduce that problem, so thank you for the method.

    Unfortunately I can't figure out what causes it and think it's something in the Unity engine. I might have to ask a Unity developer for ideas.

    Do you know if it occurs in build? I notice when I move the cursor over the editor hierarchy the flickering/orientation problem completely stops and behaves like normal. Very odd.
     
  30. Festina_Lente

    Festina_Lente

    Joined:
    Nov 9, 2017
    Posts:
    14
    Yes, sometimes it occurs and sometimes not. I did not have much time to test it, but it behaves in strange way in the build too. There it looks like a collision in the wrong place. Before geometry or within geometry.
     
  31. Festina_Lente

    Festina_Lente

    Joined:
    Nov 9, 2017
    Posts:
    14
    Hi neon_teebar, have you any news about overlapped cameras problem?
     
  32. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    No unfortunately. But I don't get the problem on 2017.3.0f1 (Linux).

    Maybe I'll have to write a custom split screen system, by drawing to a RenderTexture and Graphics.Blit that into the top right.
     
  33. daniel-griffiths

    daniel-griffiths

    Joined:
    Jun 14, 2016
    Posts:
    27
    Hello, I am looking for a way to find out the color/gradient of a collision/contact point. I then intend to render stuff to that point.

    So ideally I would like to get bump map/ height map data of the contact collision point,
    Would your asset allow me to achieve this?

    Thanks Daniel
     
  34. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    It will return the uv, and if you are doing a raycast against a single object it will return the _MainTex in hitInfo.data.

    If SuperRaycast.USE_BUMPMAP and SuperRaycast.USE_HEIGHTMAP are set to true the returned hit point and hit normal will be calculated with the bump and height textures.

    Also the Texture2D class has GetPixelBilinear which you could plug the returned uv into if you wanted to read a specific texture.
     
  35. Carpet_Head

    Carpet_Head

    Joined:
    Nov 27, 2014
    Posts:
    258
    Edit: so I took the plunge and it works really well, except for the performance. I'm getting huge times in the profiler for Gfx.ReadbackImage.

    At this time it is unusable, taking 8-13ms per frame. Is there anything that can be done to improve this? (compute shader? async readback? I don't mind a one frame delay on the data too much)
     
    Last edited: Jan 11, 2018
  36. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    Getting data from the GPU to CPU is unavoidably slow. I tried with compute shaders and async techniques and neither changed performance much.

    But 8-13ms seems really high. How many rays are you casting and what is your platform? People have been able to cast multiple rays while in VR with high performance.
     
  37. Festina_Lente

    Festina_Lente

    Joined:
    Nov 9, 2017
    Posts:
    14
    I am using 2017.3.0f3 (windows) and it works in the editor, but don't when I build it.
     
  38. Cicaeda

    Cicaeda

    Joined:
    Sep 29, 2017
    Posts:
    34
    I'm also getting insanely bad performance due to Gfx.ReadbackImage, costing nearly an entire millisecond just for 1 raycast. I'm using Unity 2017.3.0f3.
     

    Attached Files:

  39. Carpet_Head

    Carpet_Head

    Joined:
    Nov 27, 2014
    Posts:
    258
    One ray per frame using the latest SteamVR SDK on windows
     
  40. TheHawkules

    TheHawkules

    Joined:
    Jan 2, 2016
    Posts:
    4
    Chiming in, also having a large perf hit from Gfx.ReadbackImage -> about 14ms using 2 rays per frame on Windows Standalone. Unity 2017.1.1
     
  41. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
  42. Fairennuff

    Fairennuff

    Joined:
    Aug 19, 2016
    Posts:
    88
    As a note to anyone having issues with this asset and performance. Be very careful which SuperRaycast method you use! I had a similar issue at first when using the generic because it raycasts against ALL renderers in the scene. Teebar did an update a while ago that lets you raycast against 1 renderer. So now I do a normal raycast against the collider to get a single renderer and then do a super raycast against that particular renderer.

    My project is a VR game as well and don't see any noticeable perf hits when doing this.

    @neon_teebar - I do see this message in the warnings often. Is superraycast trying to change cam FOV?
    Cannot set field of view on this camera while VR is enabled.

    UnityEngine.Camera:set_fieldOfView(Single)

    SuperRaycast:SetupCamera(Vector3, Vector3) (at D:\DenOfTheives\Assets\Plugins\Teebar\Super Raycast\SuperRaycast.cs:167)

    SuperRaycast:Raycast(Ray, Renderer[], RaycastHitRenderer&, Single) (at D:\DenOfTheives\Assets\Plugins\Teebar\Super Raycast\SuperRaycast.cs:684)

    LedgeClimb:FixedUpdate() (at D:\DenOfTheives\Assets\_Scripts\LedgeClimb.cs:130)
     
  43. Fortitude3D

    Fortitude3D

    Joined:
    Sep 7, 2017
    Posts:
    155
    are you sure its better thrn a notmal raycast?
     
  44. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    Yes I should have made this more noticeable:
    I also plan on writing some kind of octtree system which can automatically track objects, which should be faster than all the above setups.

    I create a separate (invisible in the hierarchy) camera to render stuff to. It doesn't touch whatever cameras you are using, but I'll see if I can find away to prevent this warning.

    It isn't faster. Unity's is 400x faster, as mentioned in a previous post. But it has it's strengths, like working on SkinnedMeshRenderers, objects without colliders, and reading normal map + height map textures.

    "Super Raycast" might have been an unintentionally deceptive name? I was just trying to think of a name that would stand out and had Super Mario on my mind.
     
    Last edited: Feb 24, 2018
    brisingre likes this.
  45. halecc

    halecc

    Joined:
    Dec 17, 2016
    Posts:
    33
    Do you plan to support spherecast in the future?
     
  46. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    Not any time soon. I have a theory on how to do meshcasting which could cast any shape, sphere or otherwise. But it will need to use a compute shader and I've not even started trying to figure it all out.

    Features coming in the next version (when I can get around to it):
    • Octree system, for easier setup and faster testing.
    • Color masking, a technique for determining which part of a mesh was hit, like face, nose, mouth etc. It also has a post processing overlay system that can render specific masked areas.
    • New technique for testing against MeshFilters (or just meshes with no GameObjects) which is much faster, and doesn't use a Camera so it works in the editor and has fewer overall problems.
    • Batched reading. Reads multiple raycasts at once for slightly faster speed.

    Also would anyone happen to know of a technique to return a specific vertex from a shader?
    This is probably an impossible problem, but I know I can access the vertex id like this.
    Code (CSharp):
    1.  
    2. struct appdata
    3. {
    4. uint vertexID : SV_VertexID;
    5. }
    Just dunno the best way to get it from vert to frag and then frag to color and then color to index.
    From frag I could try EncodeFloatRGBA(vertexID / _TotalVertices), and then decode on the CPU, but that probably won't be reliable enough. Especially with lots of vertices in a mesh.
     
    Last edited: Mar 1, 2018
    Fibonaccov likes this.
  47. halecc

    halecc

    Joined:
    Dec 17, 2016
    Posts:
    33
    Ah ok, very awesome work btw and i am looking forward to those features, best of lucks!
     
  48. halecc

    halecc

    Joined:
    Dec 17, 2016
    Posts:
    33
    Hey teebar,

    I just wanted to let you know about 2 very minor problems. I am using Unity 2017.1.3f1.

    1. In the SkinnedMesh Demo when i move the editor camera it seems that the hit points start flickering.

    2. When i make the hit point spheres smaller (scaled at .005) the points are not hitting the mesh, if i offset them -.01 in the z direction they seem alot closer.

    Not sure if there are intended or unintended consequences but would like to know.
     
  49. neon_teebar

    neon_teebar

    Joined:
    Jun 1, 2017
    Posts:
    46
    Flickering is a problem I've been getting in newer versions of Unity. I've tried some things to fix it and have a few more ideas, but I don't currently know of a solution.

    I did come up with a new method of raycasting that works without intermittent flickering, and works perfect inside the Unity editor, but it doesn't work for animated meshes (SkinnedMeshRenderer). It'll be in the next version once I can finalize it.

    Oh, I know why that is. The objects are rendererd to a 2x2 texture where the top left pixel gives the normal and the top right gives the distance. I had never tested on such small objects.

    I will work on a version that is just 1x1, but it'll only be able to return either the hit point or the normal.

    Until then you could try going into SuperRaycast.cs in the SetupCamera method and change

    Code (CSharp):
    1. // This...
    2. camera.orthographicSize = .0001f;
    3.  
    4. // to maybe this?
    5. camera.orthographicSize = .0000001f;
    6. // or maybe
    7. camera.orthographicSize = float.minValue;
    I'll look into it. Thank you for telling me.
     
  50. halecc

    halecc

    Joined:
    Dec 17, 2016
    Posts:
    33
    Just some updates on things i found as of now.

    For normal meshes the orthographic sizes .0001f, .0000001f; float.minValue do not make a difference in accuracy, .0001f seems to work as good as float.minValue.

    For skinned meshes if i set the value to .0000001f or float.minValue it does not seem to make a difference. Now if i close unity and reopen, .0000001f seems to not detect the mesh and setting it to float.minValue gives me the error in the attachment.

    Anyways i can work around these minor problems but am looking forward to your updates! Thanks.

    Edit: I have also noticed something that doesn't seem to occur in normal racyasting, perhaps you could help me with this. I am trying to detect different meshes by superraycasting and wherever there is a hit i superraycast a bit past the hitpoint to detect the next mesh but when i superraycast again it detects the same point, so for detecting a mesh within a mesh it takes 4 iterations as oppose to 2 because it hits the same mesh. I changed my code to normal raycasting and it does not do this. Have any idea what this might be?

    Edit2: I am also having trouble detecting a hit with a renderer array if it has more than 2 mesh renderers in the same line of sight.
     

    Attached Files:

    Last edited: Mar 12, 2018