Hi, I want to make the player to see the ghost when he turn the light on him.
To do this you would first want to add an object to the flashlight, a very thin long empty box for collisions (put this as a sort of reticle in the center scope of the flashlight and as long as the light distance), then you would add a code to the ghost so that when there is that collision of that reticle object, the ghosts objects transparency would lessen (as long as it has a material that supports it), and revert back when not looking at it. Will add example code below as soon as I get it looking better.
Good luck! @siren
if it is a 3d game you could create a new cube, cylinder, pyramid or import a model which will become the collider, next you make it a child of the flashlight(so it will follow its movement), than position it to align with the light and turn the mesh renderer of the object of to make it invisible, next add a collider to it(using add component) and give it the same shape, check the is trigger box. and hive it a tag with the name flashlight.
After that go to the ghost uncheck the checkbox of the mesh renderer.
create a c# script and add the 2 voids below to the script.
after that add the script to the ghost and it should work
void OnTriggerEnter (Collider other){
if(other.tag="flashlight"){
GetComponent<MeshRenderer> ().enabled = true;}
}
void OnTriggerExit (Collider other){
if(other.tag="flashlight"){
GetComponent<MeshRenderer> ().enabled = false;}
}
I still need some help
I can’t figure the code.