- Home /
Invisible objects between players and camera..
Hello! I have an issue with my 2d topdown rpg: id like to make invisible objects between player and camera, like roofs or secret passages.. I found this answer interesting, but i don't know if could really help me: http://answers.unity3d.com/questions/588271/hiding-objects-between-my-character-and-camera-how.html and i don't know how to setup the complete script.. Could anyone gently help me, by explanaing how to setup scripts and objects of that answer or suggesting other possible solutions? Sorry, i'm an unexperinced Unity user. :)
Thanks in advance!
Nic
Answer by blackcoper · Jun 05, 2014 at 07:08 AM
you can use collider for trigger. if player enter set roof invisible. when player leave set visible back.
OH! So simple and so effective.... $$anonymous$$any many thanks blackcoper! ^_^
Answer by Kiwasi · Jun 04, 2014 at 11:27 PM
Any object can be made invisible simply by removing or disabling its renderer component
Thanks for your answer mate! But i actually need to make invisible objects between player and camera like roofs, but im not so expert in using raycast. :)
Answer by ZodiaXCorpX · Nov 11, 2015 at 01:25 PM
Hello i have searched for this answer and i kept finding other idea's that are either complex ray-casting or resource heavy triggers. I have a simple solution for anyone that comes across this and im necroing an old post for the reason this comes up first in the search.
Create a box collider put it on your camera set rotation and position to 0 then on the Z axis streach it all the way to your player. Then add this script
Public void OnTriggerEnter(Collider other) { if(other.tag != "Player") { other.gameObject.getComponent().enabled = false; } }
Sorry for any spelling errors, This will turn OFF the renderer of any game object that comes between player and camera and its completely customizable with size since you can adjust the box collider to fit your needs :) This is C# and for the tag if your player is not tagged "Player" Or if you want to make exceptions just do this if(other.tag != "MyGuy" || other.tag != "DontDisableMyRenderer") ETC.
Answer by toorican · Dec 10, 2021 at 10:20 AM
Hi If your still looking for a solution check our Asset as this is custom made shader 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/ https://assetstore.unity.com/packages/vfx/shaders/see-through-shader-193955 https://www.youtube.com/watch?v=9X9aVJzzBlI
Your answer
Follow this Question
Related Questions
how to ignore transparency of image when clicking/raycasting on it in 2D/uGUI? 0 Answers
Change multiple object layers 0 Answers
Need raycast to target child, not parent. 0 Answers
Can't Ignore a Layer when raycat 0 Answers
layers not ignored by raycast 1 Answer