Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Slender: The Arrival 'focus flashlight' script?

Discussion in 'Scripting' started by Deleted User, Oct 27, 2016.

  1. Deleted User

    Deleted User

    Guest

    Hey, guys. I need help recreating a feature from the 2013 Unity horror game Slender: The Arrival. I'm talking about the "focus" feature when using the flashlight. For those of you who have no idea what I'm talking about, it's actually quite simple. Please refer to the following video, as it basically shows you everything I'm talking about:

    If you were paying attention in the video or are just too lazy to even watch it, there seems to be some sort of state where the flashlight is focusing in on a specific target (in this case, the hooded creature in the video).

    I thought this feature was pretty unique and was wondering how I could replicate it for a horror game I am making. If anybody knows how I can do this, I'd greatly appreciate if you could give me some tips on how I can make my player's flashlight do the same thing. Please and thank you in advance! :)
     
  2. Piflik

    Piflik

    Joined:
    Sep 11, 2011
    Posts:
    289
    I don't think that the flashlight focuses on the target automatically, the player controlls it. But if you want the flashlight to point towards the target, all you need to do is determine if an enemy is in view (for example via the OnBecameVisible() method) and then use a LookRotation to rotate the flashlight (and probably the arm) to point in that direction.

    But if you refer to the beam getting narrower, I also think that this is done with a button by the player, but it can be triggered automatically as I outlined above, too. All you need to do there is change the spotlight angle of the lightsource.

    Edit:Oh...and don't call people lazy if they don't watch a video, after you're too lazy to explain your problem properly. Especially not, if you want these people to help you...
     
    Deleted User likes this.
  3. Deleted User

    Deleted User

    Guest

    Thanks for your help, man! And uhhh...sorry about that.