- Home /
See Through Objects in Top Down Shooter
Hi, I am currently creating a top down shooter game, one of the problems I seem to run into in my game is not being able to see the player if he goes underneath a piece of geometry(plane, cube, etc)
I was looking to see if there was a way to have it to where the player went behind one of these objects that it makes the object see through
I did a little research, and from what I gathered I would have to use a Raycast between my player and the camera, something like
Cast raycast from camera to player, if it hits player, do nothing, if it hits object, set opacity to 50% or something.
Any help or suggestions would be greatly appreciated!
haha glad to see that my brain somewhat works at 2am! now to do the fun job of learning syntax!!!
Couldnt I just set the texture to a Transparent/Bumped Diffuse shader and alter the Alpha via script?
That would work as well but increase draw calls more if there are a lot of instances in the scene.
Ok I got the raycast to output the line, but for some reason I cant get it to point to my player! It will follow the player as it moves around, but it seems like its offset by a huge margain.
Heres the code I have...
var target : Transform;
function Update ()
{
Debug.DrawRay(transform.position,target.position,Color.green);
if (Physics.Raycast(target.position, transform.position))
{
Debug.Log("Something in the way");
}
}
Here is an image representing what my problem looks like!
Let me know if there is anymore info you need!
Answer by FWCorey · Mar 06, 2013 at 07:51 AM
That's exactly what you need to do. There are several ways of doing the transparency and which way you choose to do it depends on your project. If there are very few objects that you would have to make transparent then the easiest is to have 2 materials for each. You would then place a script on each object that sets the transparent material for a short period of time when told and then sets it back. Your raycast script would use GameObject.SendMessage() to tell it to reset the timer as long as the rays keep hitting it. No fuss, no muss. :)
Answer by toorican · Jan 04 at 06:20 PM
Hi If your still looking for a solution check our Asset as this is a custom made Asset for this use case. It can handle multi user multi buildings ( obstructions ) and is available for Standard URP and HDRP .
https://forum.unity.com/threads/rel...isible-within-buildings-std-urp-hdrp.1182130/
Asset: https://assetstore.unity.com/packages/vfx/shaders/see-through-shader-193955
WebGL Demo: link text
Video: link text
Greetings Toorican alt text
Your answer
![](https://koobas.hobune.stream/wayback/20220613093918im_/https://answers.unity.com/themes/thub/images/avi.jpg)