Make an Actor always behind others
I'm currently making some space environment - to use something more creative than skybox I made Earth and stars as other actors. Because of technical issues I can't make them further than ~20-30.000 units (...300 meters? Great cosmic space, dude), but I solved problem of parallax scrolling with translating sky with the player.
Now this solution turns against me - when I build something larger than 300 meters, like landscape, all illusion falls:
I can't spawn Earth and stars further than now. So I thought - can we set them to other layer to be always behind other objects? Even when Earth has 10 cm of diameter and is technically 10 cm over our heads?
Ah - if possible, tell me also how to set a layer from level of C++.
asked Aug 12 '16 at 01:53 PM in Using UE4
I found it! In short, you need to set the value of Pixel Depth Offset in Material settings to some sick large value. I'm not sure of form of this variable - is it Vector3? Vector4? but with method of trying and failing I found that making vector of form (1e9,0,0) works:
Second case is subtle - even if your material will have offset to behind all items, it will still cast shadows - so we will have some 'ghost' of our object in place of it's real position, even if object itself is visible far behind scene. The solution to this problem is simple - I just used method SetCastShadow of MeshComponent with given argument false. The shadow was still on Earth, but Earth itself wasn't giving shadow any more.
answered Aug 14 '16 at 10:58 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here