I am making a horror game, its in first person, and I have a Flashlight working. The thing is that I wanted that if i’m in the dark, and I point the light of my flashlight to a “monster”, a loud sound gets activated, just with the contact of the light with the enemy. I was solving the problem for this common horror movie/game effect for a while and the best that I have right now is a cone atached to the first person view, with the form of the projected light of my flashlight, that works as a Trigger for the sound effect.
1)The problem is that the cone it’s not having the same movement of the light that the flashlight projects… I think just the small side of the cone should be attached to the camera, to create some sort of rotation movement from this poin. Does anyone know a way to attach the cone to the camera so it does the same movement as the light?
2) The second problem is the Script, it work with a tag, so when the tag enemy collides with this trigger, a sound will be played. By far, it’s not working when its attached to the camera…But I tested it tagging my player as “enemy” and it does work, only that it’s a stationary cone on the air, and not the “moving with the light” cone that I need.
Here it’s an image I did to explain the idea:
[3276-idea+juego+foto.png|3276]
-THE SCRIPT (It gets attached to the cone, with a mesh collider integrated, and the option “IsTrigger” and “Convex” activated. The cone its attached to the main camera, and it must have the form of the light projected from the flashlight. The enemy its a capsule, with capsule collider, with the trigger option desactivated):
var Sound : AudioClip;
function OnTriggerEnter(item : Collider)
{
if(item.tag == "Enemy")
audio.PlayOneShot(Sound);
}
I hope there are some ideas to make this work, it would be a really good contribution to anyone on this comunity who wants to make a horror game;)