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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

3D visibility according to player's position

Discussion in 'Getting Started' started by JoKe90, Oct 2, 2015.

  1. JoKe90

    JoKe90

    Joined:
    Jun 10, 2015
    Posts:
    15
    Hi everyone.

    I'm n00b in Unity and C#.
    I'd like to make something like Hotline Miami, but in 3D and so that player can't see through walls. I don't know where to start, but I found this nice article:
    http://www.redblobgames.com/articles/visibility/

    I can't seem to find help to make something similar in Unity and code in the article is too hard to read for me.
    Can someone make sample code or perhaps give me a link to tutorial?

    Edit: The picture I attached is bad... It would be better to show the player walls and stuff instead of just black. :)

    wut.png
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,848
    Well, why not just use a first-person view? Then you automatically can't see anything that can't be seen from the player avatar's position.

    It's certainly possible to do ray-casting to selectively show/hide stuff even in a top-down view... but it's a lot more work, and less intuitive for the player.
     
  3. JoKe90

    JoKe90

    Joined:
    Jun 10, 2015
    Posts:
    15
    "Why not just use a first-person view"
    What do you mean? I don't want to make FPS if that is what you mean.
    If you mean combining some cameras and having the main camera show only stuff that other cameras see then how can I make something like that?
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,848
    No, I meant a first-person view (like a first-person shooter, but not necessarily with the shooting).
     
  5. MurDocINC

    MurDocINC

    Joined:
    Apr 12, 2013
    Posts:
    265
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You could certainly make a fake by putting your only light source on the player. You might even be able to use a shader to get a more sophisticated version of the effect. No point rewriting the entire raycasting thing when Unity's lighting model already handles it.
     
    JoKe90 likes this.
  7. JoKe90

    JoKe90

    Joined:
    Jun 10, 2015
    Posts:
    15
    Thanks for the link. It helped me to get idea how to approach the problem, but it isn't exactly what I'm looking for.

    That sounds pretty good, but does Unity have a light that is evenly lit?