# How to set up custom depth on a recursively spawned actor (surface-oriented mouse cursor)

**URL:** <https://forums.unrealengine.com/t/how-to-set-up-custom-depth-on-a-recursively-spawned-actor-surface-oriented-mouse-cursor/1808152>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [April 17, 2024, 2:34pm UTC](https://forums.unrealengine.com/t/how-to-set-up-custom-depth-on-a-recursively-spawned-actor-surface-oriented-mouse-cursor/1808152 "2024-04-17T14:34:35Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![flyingmonkey398](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@flyingmonkey398](https://forums.unrealengine.com/u/flyingmonkey398)\
**Post date:** [April 17, 2024, 2:34pm UTC](https://forums.unrealengine.com/t/how-to-set-up-custom-depth-on-a-recursively-spawned-actor-surface-oriented-mouse-cursor/1808152/1 "2024-04-17T14:34:35Z")

</div>

Hello. I have created a surface-oriented mouse cursor, similar to this example [How to setup a surface oriented mouse cursor](https://forums.unrealengine.com/t/how-to-setup-a-surface-oriented-mouse-cursor/426850). Now, I would like to add custom depth to it, so that it doesn’t go through the corners of walls like so

 ![Screenshot 2024-04-17 at 5.30.16 pm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/6/a/86a1d495932c02d1fdaf256034da51e42661c21a.jpeg)  
, but rather appears on top of them. How could I achieve this? Thank you.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 17, 2024, 4:20pm UTC](https://forums.unrealengine.com/t/how-to-set-up-custom-depth-on-a-recursively-spawned-actor-surface-oriented-mouse-cursor/1808152/2 "2024-04-17T16:20:21Z")

</div>

Have a look at what decals can do:

> **[Using Decal Materials in Unreal Engine](https://docs.unrealengine.com/4.26/en-US/Resources/ContentExamples/Decals/)**
>
> A guide to working with and using decals in your Unreal Engine projects.

Sounds like that’s what you’re looking for.

---

<div class="post-metadata">

**Author:** ![flyingmonkey398](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@flyingmonkey398](https://forums.unrealengine.com/u/flyingmonkey398)\
**Post date:** [April 18, 2024, 9:36am UTC](https://forums.unrealengine.com/t/how-to-set-up-custom-depth-on-a-recursively-spawned-actor-surface-oriented-mouse-cursor/1808152/3 "2024-04-18T09:36:29Z")

</div>

I am finding that decals will bend to accord with the mesh geometry. This is why I opted for spawning a partially transparent plane. What I’m looking for is for this plane to appear over top of every mesh like so:

 ![Screenshot 2024-04-18 at 12.36.03 pm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/4/6/f467c77c3f2dda3472777657c75f426da26d2841.png)  
Much appreciate it!

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 18, 2024, 9:44am UTC](https://forums.unrealengine.com/t/how-to-set-up-custom-depth-on-a-recursively-spawned-actor-surface-oriented-mouse-cursor/1808152/4 "2024-04-18T09:44:36Z")

</div>

Look into decal tri planar projection ← that’s the keyword to search for. As in:

[https://www.unrealengine.com/marketplace/en-US/product/x-decal-tri-planar-projection?sessionInvalidated=true](https://www.unrealengine.com/marketplace/en-US/product/x-decal-tri-planar-projection?sessionInvalidated=true)

> **[Decal - Triplanar UV Material Function posted by RonanMahonArt | blueprintUE...](https://blueprintue.com/blueprint/p5zc-m__/)**
>
> Triplanar UV mapping function for use with Decals. 
> Note decals cannot write to the normal channel as the SceneTexutre:WorldNormal is being read, therefore cannot be used with Decals which need to contain Normal maps.
> Use this Material Function as...

There’s should be some examples around. Don’t have _the definitive tut_ at hand.

* * *

> bend to accord with the mesh texture

Geometry, right?

* * *

> What I’m looking for is for this plane to appear over top of every mesh like so:

Not sure if I’m recommending the right technique. Are we talking about disabling depth? Now that I read the topic again, it seems that you want something entirely else than I thought. My bad.

---

<div class="post-metadata">

**Author:** ![flyingmonkey398](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@flyingmonkey398](https://forums.unrealengine.com/u/flyingmonkey398)\
**Post date:** [April 19, 2024, 6:54am UTC](https://forums.unrealengine.com/t/how-to-set-up-custom-depth-on-a-recursively-spawned-actor-surface-oriented-mouse-cursor/1808152/5 "2024-04-19T06:54:49Z")

</div>

Thanks for the response. What I’m looking for is for my spawned actor (mouse cursor) to receive location and rotation from real geometry and to spawn on the desired location, however, to appear over top of all geometry (from my research sounds like custom depth). I am providing a video for reference on how the cursor works, and what I’m looking for is to avoid if falling through geometry.

PS. I looked into Triplanar UV’s and I’m not sure that that is what I’m looking

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 19, 2024, 7:31am UTC](https://forums.unrealengine.com/t/how-to-set-up-custom-depth-on-a-recursively-spawned-actor-surface-oriented-mouse-cursor/1808152/6 "2024-04-19T07:31:56Z")

</div>

> avoid if falling through geometry

Still not not sure I get it. Which part of this is undesirable?

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/5/5/75532a4dc53cd02ab00b5358be502cd961f9d2d2.png) ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/c/9/1c9efe5b06bfbcc68693fc37f900085aa66f2aee.png)

What would be the ideal way to have it displayed?

---

<div class="post-metadata">

**Author:** ![flyingmonkey398](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@flyingmonkey398](https://forums.unrealengine.com/u/flyingmonkey398)\
**Post date:** [April 20, 2024, 6:28am UTC](https://forums.unrealengine.com/t/how-to-set-up-custom-depth-on-a-recursively-spawned-actor-surface-oriented-mouse-cursor/1808152/7 "2024-04-20T06:28:04Z")

</div>

The second one is undesirable, I would like to see the whole cursor at all times. This would be an example of the way I would like to see it displayed [How to set up custom depth on a recursively spawned actor (surface-oriented mouse cursor) - #3 by flyingmonkey398](https://forums.unrealengine.com/t/how-to-set-up-custom-depth-on-a-recursively-spawned-actor-surface-oriented-mouse-cursor/1808152/3)

Thank you very much!

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 20, 2024, 7:02am UTC](https://forums.unrealengine.com/t/how-to-set-up-custom-depth-on-a-recursively-spawned-actor-surface-oriented-mouse-cursor/1808152/8 "2024-04-20T07:02:57Z")

</div>

But this can be achieved by disabling depth test on the material, no? Is that it?

---

<div class="post-metadata">

**Author:** ![flyingmonkey398](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@flyingmonkey398](https://forums.unrealengine.com/u/flyingmonkey398)\
**Post date:** [April 20, 2024, 9:24am UTC](https://forums.unrealengine.com/t/how-to-set-up-custom-depth-on-a-recursively-spawned-actor-surface-oriented-mouse-cursor/1808152/9 "2024-04-20T09:24:47Z")

</div>

I was able to get custom depth to work by changing my blend mode to on the material from mask to transluscent, and then ticking “Disable Depth Test”. However, this boxed in my plane into a single color and thus the circular mask of the cursor shape was lost. Is there any way to achieve custom depth while maintaining the material blend mode at “Mask”? Thank you very much!

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 20, 2024, 9:28am UTC](https://forums.unrealengine.com/t/how-to-set-up-custom-depth-on-a-recursively-spawned-actor-surface-oriented-mouse-cursor/1808152/10 "2024-04-20T09:28:15Z")

</div>

Can you show the material? Are you piping alpha into `Opacity`?

---

<div class="post-metadata">

**Author:** ![Michael\_page](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/michael_page/32/911378_2.png) [@Michael\_page](https://forums.unrealengine.com/u/Michael_page)\
**Post date:** [May 8, 2024, 11:48pm UTC](https://forums.unrealengine.com/t/how-to-set-up-custom-depth-on-a-recursively-spawned-actor-surface-oriented-mouse-cursor/1808152/11 "2024-05-08T23:48:57Z")

</div>

I don’t know if it can help, but your transluency method in prost-processing must be set to raster to work (if set to raytracing, depth test will not disable).
