I am developing an indie horror video game as a spin-off to Slender: The Arrival. In the game, the main antagonist (named the Chaser) is very sensitive to light. Which allows the player to temporarily stun her with their flashlight. How can I recreate this in Unity 5 and C#? Here’s the code that I have already
public class BlindChaser : MonoBehaviour
{
public Transform Player; //The character the person playing controls in-game.
public NavMeshAgent Chaser; //The main antagonist of the game.
public Vector3 ChaserDistance; //The Chaser's distance away from the Player.
}
void Update()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
if (hit.collider.CompareTag("Chaser"))
{
bool ChaserFound = false;
}
if(hit.collider.gameObject("Chaser"));
{
Debug.DrawRay(transform.position, ChaserDistance * 30, Color red);
ChaserFound = true;
GetComponent<Animation>().Play("stun");
}
Is this code right. If not, what can I do to improve it to resemble when the player does this in Slender: The Arrival? If you don’t know what I’m talking about, please watch the following video: