Slender Man -- Design Outline

Discussion in 'Collaboration' started by AgentParsec, May 5, 2012.

  1. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    Will a capsule cast work though? I would think that it would register the first obstacle it hits, such as the wall SM is sticking out from behind...
  2. TehWut

    TehWut

    Member

    Joined:
    Jun 18, 2011
    Messages:
    1,579
    hm.....I'll see if I can get something working here
  3. TehWut

    TehWut

    Member

    Joined:
    Jun 18, 2011
    Messages:
    1,579
    you're right - I created a basic raycast detection, and you can infact sneak up on 'em
    (sloppy code0
    Code (csharp):
    1. #pragma strict
    2. var pointer: GameObject;
    3. var range:int = 0;
    4. var canSee:boolean = false;
    5. function Start () {
    6.  
    7. }
    8.  
    9. function Update () {
    10. pointer.transform.LookAt(target);
    11. if (Physics.Raycast(pointer.transform.position,pointer.transform.forward,hit,range))
    12.     {
    13.         if (hit.collider.gameObject.tag == "Player")
    14.             {
    15.     Debug.DrawRay(pointer.transform.position,pointer.transform.forward,Color.red);
    16.         print(" can see!");
    17.         canSee = true;
    18.             }
    19.         else
    20.             {
    21.             canSee = false;
    22.             }
    23.  
    24. }
    25. else if (!Physics.Raycast(pointer.transform.position,pointer.transform.forward,hit,range))
    26.     {
    27.     canSee = false;
    28.     }
    29.  
    30. }
    - After slapping that on Slenderman. Pointer is a seperate empy gameObject, used for looking at the player constantly, and then checking raycasts. Is it professional? No. Does it work? pretty damn well. Here is what I am thinking -

    - have multiple "pointers" surrounding Slenderman. This could give him increased visibility and angles through this "orb of eyes' technique. However, raycasting all these pointers are expensive, and difficult to be dynamically placed.

    - Use my method for Slenderman detection. Then, use a raycast detection on the player as well. Raycast from the center of the player screen, this way, a raycast will go off if the player is looking at him at all - preventing sneaks. The standard Slendy detection will also counter as a second form of detection, if, for example, you just back into an area where he is.

    edit. *sigh*. for my method to work, your crosshair will have to be directly over him... foiled again!
    I guess you could also try a shotgun based raycast. That is expensive though. but wait....
    what if the player also had a pointer object just in front of them? this should cut back on some of the sneaking for sure.

    In all of my ramblings, I still believe two different pointers for the player and slendy are the way to go
    Last edited: May 19, 2012
  4. AJCStriker

    AJCStriker

    New Member

    Joined:
    Apr 10, 2012
    Messages:
    19
  5. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
  6. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    I just realizes that the current spotting system can still sort of work. Seeing only a small part of SM is something I can deal with when it comes to the sanity loss. The problem lies in the possibility of SM teleporting while part of him is visible. That being the case, the solution mentioned above about testing some extra points around SM would work for at least determining that there's little chance he's visible. I can live with that if need be. I will try this later and see how well it works.

    I'm learning little by little.
    Last edited: May 20, 2012
  7. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    I'm not sure how to go about starting the spotting thing exactly, so for now I'm turning my attention back to picking up pages.

    Here's the code I have for it so far, but it's not working. I'm not sure what's wrong with it exactly:

    Code (csharp):
    1.  
    2.     void Update () {
    3.        
    4.         RaycastHit hit;
    5.         var fwd = transform.TransformDirection (Vector3.forward);
    6.        
    7.         if (Input.GetMouseButtonDown(0)) {
    8.             if (Physics.Raycast(transform.position, fwd, out hit, 1)) {
    9.                 if (hit.collider.gameObject == page.gameObject) {
    10.                     Debug.Log ("Page grabbed!");
    11.                     Destroy(page.gameObject);
    12.                 }
    13.                 else Debug.Log ("That's not a page.");
    14.             }
    15.             else Debug.Log ("Nothing found.");
    16.         }
    17.     }
    18.  
    What's currently happening is that it will say "Nothing found." if there's nothing within a distance of 1 in the direction the player is looking. If there is something, but it's not a page, it says, "That's not a page." instead. What it SHOULD be doing is saying, "Page grabbed!" when the object the raycast hits is the page, but it's not doing that, it's just going, "That's not a page." like it would with any other object. The page is a cube right now, and it's definitely solid. I'm sure it's something in the part where it tests to see what object was hit. Can someone correct this?
  8. ludiares

    ludiares

    Member

    Joined:
    Jul 14, 2011
    Messages:
    220
    I think this would work better, and is quite more simple:
    Code (csharp):
    1.  
    2.     void OnMouseDown()
    3.     {
    4.         Debug.Log("Page Collected");
    5.         GameObject.Find("Player").PlayerScript().pages++;
    6.         Destroy();
    7.     }
    8.  
  9. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    If I understand OnMouseDown() correctly, wouldn't that work only if you actually click the mouse on the page when it's onscreen? And also at any distance from it? Or does it have some other use?
  10. ludiares

    ludiares

    Member

    Joined:
    Jul 14, 2011
    Messages:
    220
    It would work whenever you clicked the page when it's on screen, but you could add a Vector3.Distance check so you can click it only on a certain distance, something like this
    Code (csharp):
    1.     void OnMouseDown()
    2.     {
    3.         if(Vector3.Distance(transform.position, GameObject.Find("Player").position) <= 2)
    4.         {
    5.             Debug.Log("Page Collected");
    6.             GameObject.Find("Player").PlayerScript().pages++;
    7.             Destroy();
    8.         }
    9.     }
  11. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    Is there a way to lock the mouse in the center of the screen? Since it's being used currently to look around, it's exceedingly difficult to click on something without swinging the view around.
    Last edited: May 20, 2012
  12. ludiares

    ludiares

    Member

    Joined:
    Jul 14, 2011
    Messages:
    220
    Using this:
    Screen.lockCursor = true;
  13. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    Little by little, everything's improving. Pages are picking up now, but I'm doing something wrong with the variables that count the pages you've collected so far. How do I set up global variables on the player object, and how do I check or modify them in the objects of other scripts?

    Sorry about this, I'm just not used to C#. Once I know how to do this, though, I can combine it with what I already know to complete the sanity level scripting.
  14. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    The way I plan to do the sanity scripting is that it starts at some high value, then drops whenever SM is visible at a rate dependent on the distance between the player and SM. Since all of the visibility info is on SM's script, I should probably have the same script do all the modifications to the sanity stat as well.

    Just for my own reference (since I'm not in a position to code at the moment), here's the pseudo-code:

    General declarations:
    Code (csharp):
    1.  
    2. maxdist = (maximum distance for sanity loss to occur);
    3. mult = (multiplier that will be applied to dist);
    4. maxdrain = (maxdist * mult);
    5. rec = (recovery amount);
    6. maxsan = (maximum sanity level);
    7. sanity = (maxsan);
    8.  
    Function:
    Code (csharp):
    1.  
    2. dist = (distance between SM and player);
    3.  
    4. if (SM is visible) {
    5.      if (dist < maxdist) {
    6.           sanity -= (maxdrain - (dist * mult));
    7.           if (sanity <= 0) end game;
    8.      }
    9. } else if (sanity < maxsan) {
    10.      sanity += (rec);
    11.      if (sanity > maxsan) sanity = maxsan;
    12. }
    13.  
    This way, sanity loss occurs at a rate between nothing (at maximum range) or extremely fast (if up close). If outside the maximum range but still visible, it will do nothing at all. If not visible, sanity will recover at the recovery rate.
    Last edited: May 21, 2012
  15. TehWut

    TehWut

    Member

    Joined:
    Jun 18, 2011
    Messages:
    1,579
    global variables are set up like this:

    Code (csharp):
    1. static var playerVariable
    at least in UnityScript that's how it is, not sure about C#...

    and then you can
    Code (csharp):
    1. GetComponent("PlayerScript").playerVariable = 55
  16. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    It doesn't seem to be working, so it must be something different for C#. Either that or I'm putting it in the wrong section of code. The error I'm getting is, "The contextual keyword 'var' may only appear within a local variable declaration".
  17. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    Okay, I did some C# research and I fixed the problem. I have gotten the following items completed:

    - Picking up pages, and keeping track of how many pages were picked up
    - Draining sanity based on distance between player and SM, and recovering sanity gradually when he is not visible

    All in all, not bad so far. The hardest part is coming up, though, and that's all of SM's movement. This I will definitely need help with, since I don't know the first thing about how to actually script any of his movement.

    In all, he needs to:

    - Roam whenever the player is not seen by SM, and the player is not facing SM
    - Move towards the player whenever player is seen by SM (not necessarily the player seeing him back), and the player is not facing SM
    - Teleport to a legal position within a maximum and minimum range when:
    --- A. SM moves outside of the maximum range
    --- B. SM roams for a random amount of time without seeing the player
    --- C. The player is facing him (but does not see him), a random amount of time has passed, and there is still a chance he will not teleport at all
  18. Zethariel1

    Zethariel1

    New Member

    Joined:
    Mar 21, 2012
    Messages:
    439
    For your moving, you'd have to look into pathfinding. Legitimate spawnpoints could be the nearest nodes of said pathing system. roaming can be simply done by randomizing the state the Slenderman is -- move forward, stop, turn, move backward, and so on. Think it's called a state-machine.

    But for the sake of the game, you might as well just build a standard path that the Slenderman will follow each game -- its not that anyone will notice he moves in the same patterns while they are running away with their pants full of crap.
  19. TehWut

    TehWut

    Member

    Joined:
    Jun 18, 2011
    Messages:
    1,579
    I'm on it captain ;)

    However, I think it would also be cool to have Slenderman stationary at some points - and the player really has to think through some areas to avoid him at that one spot, kind of puzzlish I suppose. I'm really liking this so far. I'll see how far I can get with movement.

    I guess the issue here is how much you want him to move. Will it be more suspenseful? will he show up scarcely? will he appear to hunt down the player? I guess based on Slender-Lore it will be a mix of both...I need to stop talking ;) I be brushing up on my coding skills and try to make it as modular as possible.

    EDIT:
    How do you plan on implementing this? I don't exactly understand what you mean on this one.
    Last edited: May 23, 2012
  20. TehWut

    TehWut

    Member

    Joined:
    Jun 18, 2011
    Messages:
    1,579
    Ah, posting again!!

    What type of levels were you exactly planning?

    The beauty of forest levels is that they would be supa easy to randomly generate, and with an added benefit of (relatively) easy atmospherics

    [​IMG]
    Last edited: May 23, 2012
  21. MellowNinja

    MellowNinja

    New Member

    Joined:
    Mar 26, 2012
    Messages:
    345
    lol reminds me of the scene in zelda majoras mask :p except ist more gloomy in the picture
  22. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    What I meant by that is kind of like what you were saying before about him being stationary. If the player can't see him, but is still facing him, he will not move (that way, there's no chance that he will move into view). After a random amount of time has passed in this state, he either teleports to a new position or remains where he is (random chance of either).

    The reason for this is that if he always teleported away when the player can't see him but still faces him, the player can use that to their advantage by ducking behind cover and facing that direction until he's reasonably certain that he has moved on. On the other hand, if he just stayed stationary and didn't teleport at all, the player could also use that to their advantage, keeping him tethered to the spot by staying facing in that direction.

    By having it random, the player is never quite sure whether he will still be there or not. If he takes the chance and keeps facing that general direction, SM may have moved on behind him. Likewise, if the player is trapped, SM may not move at all, but if they look away, then SM will get even closer, creating a tense situation of whether or not to look away. Ultimately, most people playing may not even be aware of how the mechanics work, but even if they do figure it out, this random factor will at least prevent it from being predictable.

    About how much he would move: I imagine he wouldn't be there at all until after the first page is found. After that, he appears but does not actually roam or move at all, just randomly appears and stays put. Once the second page is found, he starts roaming, and as each sucessive page is found, he spawns closer and roams faster. It starts out suspenseful but quickly becomes exceedingly dangerous by the last page or two.

    About the map, wooded areas are the goal, but also some old structures where the pages can be found. Having the pages scattered randomly in the woods would be too hard to find, so having some sort of landmarks that are easily found would be preferable. It would also add some variety and give some actual cover.
    Last edited: May 23, 2012
  23. TehWut

    TehWut

    Member

    Joined:
    Jun 18, 2011
    Messages:
    1,579
    Thank you for the information, I now have a very good idea of the gameplay mechanics and the movement. However, the movement code is now going to be more complicated than I thought...

    I guess by this point I'd like to help with some code, and maybe a few models if they are good enough :|
    oh god what have I done! ;)
  24. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    A model is underway; for now, I've been just using a stretched out sphere to represent SM.

    The next thing I'm going to implement is sprinting. My plan is to have a typical stamina level that goes down when sprinting and builds back up slowly when not sprinting. However, I want to have the maximum stamina very gradually decrease as you sprint as well. This makes it so that if you sprint a lot, you wear yourself out and end up sprinting for shorter and shorter periods of time. This will also encourage players to walk more, especially at the beginning of the game where it helps build suspense.

    I figure lighting should be easy as well. I'm going to have the player carrying a flashlight, which can be turned on and off with the right mouse button (the only other control in the game). I'm going to mess with ambient lighting as well to see if there's a way I can get it to look dusk at the beginning of the game, then gradually become night. The transition wouldn't last the whole game, it'd just be something short that would be about how long it would take for the average player to find and pick up two pages or so.

    I think I've learned enough about Unity to work on the above two items myself. When I get the chance, I'll also make a quick video showing what's currently done (it's just cubes and stuff right now, nothing pretty to look at).
  25. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    Actually, let me change that. The flashlight will always be on, because I want to make sure if SM is visible that the player can actually see him.

    I just realized, is there any way to check if a light source is touching an object at all? That might be a quicker way to verify if SM is visible.
  26. TehWut

    TehWut

    Member

    Joined:
    Jun 18, 2011
    Messages:
    1,579
  27. Prion Games

    Prion Games

    New Member

    Joined:
    Jul 1, 2011
    Messages:
    1,510
  28. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    I've been using the First Person Controller in the standard assets up to this point, though I disabled jumping. There's no real need for it, and I also want to be sure the player can't jump up onto a table or some other safe perch that SM can't reach. I've also implemented sprinting and crouching, and a check for stamina that gradually wears down if you overuse it.
  29. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    I'm now pleased to say that I've implemented an early version of audio effects that play during sanity loss. Right now I'm using some stock static and feedback sounds. What it does is gradually fade a sound in based on the sanity beng at a certain level. Specfically, a very light static sound will fade in as the volume drops from 100% to 70% (below which it plays at full volume). Between 70% and 40%, a second, stronger static sound plays. Between 40% and 10%, a loud feedback sound plays. Below 10%, all three sounds are playing at full volume. The effect is that the sounds fade in one after another as your sanity drops, then gradually fade back out again as sanity builds again. Here's the code for it (earlier, three AudioSource objects are defined: san1, san2 and san3):

    Code (csharp):
    1.  
    2.         // Sanity effects
    3.         if (sanity < 100) {
    4.             if (sanity < 70) {
    5.                 san1.volume = 1;
    6.                 if (sanity < 40) {
    7.                     san2.volume = 1;
    8.                     if (sanity < 10) {
    9.                         san3.volume = 1;
    10.                     } else {
    11.                         san3.volume = ((40 - sanity) / 30);
    12.                     }
    13.                 } else {
    14.                     san2.volume = ((70 - sanity) / 30);
    15.                     san3.volume = 0;
    16.                 }
    17.             } else {
    18.                 san1.volume = ((100 - sanity) / 30);
    19.                 san2.volume = 0;
    20.                 san3.volume = 0;
    21.             }
    22.         } else {
    23.             san1.volume = 0;
    24.             san2.volume = 0;
    25.             san3.volume = 0;
    26.         }
    27.  
    What I need to do next is have a single event sound play when you change from not viewing SM to viewing him, based on your actual distance from him. This way I can make a sudden dramatic sound if he's close by when you see him (more startling), because right now it just very quickly fades in the sanity effects, which is not as startling.

    *EDIT* Okay, that's working now too, it was easier than I thought. :D

    (I'd also like to pause for a moment and thank Lukasaurus for essentially talking me out of giving up on scripting. I'm learning quite a bit, and even though I still can't grasp a lot of the higher-level stuff, I'm having fun scripting what I can.)
    Last edited: May 24, 2012
  30. Zethariel1

    Zethariel1

    New Member

    Joined:
    Mar 21, 2012
    Messages:
    439
    On a side-note, this is really turning into Unity community collaboration project :D
  31. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    Ok, I recorded a quick video to show the progress so far. My test area only has two cubes as walls, a "page" (actually another cube) floating in midair, and a stretched sphere representing SM (currently stationary). Everything is FAR from complete, including my attempt at making a flashlight. What I show off here is that I can pick up the page (for some reason, the first time I click when testing the game, it unlocks the cursor, so I had to move it back), and the sound effects for the sanity level. If I'm within 10 meters when I go from not seeing SM to seeing him, it plays the dramatic sound.

    The video is a little stretched vertically, just ignore that.



    All the sounds are temporary too. I'll probably make something from scratch.

    (*EDIT* Wow, top of the next page in the thread. Perfect! ^^)
    Last edited: May 24, 2012
  32. ludiares

    ludiares

    Member

    Joined:
    Jul 14, 2011
    Messages:
    220
    I think that instead of the first static noise sound, a quick hearthbeat sound would be better
  33. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    I agree. I'll switch that in when I switch out the other sounds.
  34. TehWut

    TehWut

    Member

    Joined:
    Jun 18, 2011
    Messages:
    1,579
    Woo! That was a pain in the ass (no it was actually really fun)

    Here you have a barebones Slenderman movement code.

    Please note, I am by no means a coder, and I'm positive everything here could be optimized or made easier to understand. My methods are far from clean, so don't take my style with a grain of salt ;)

    BEFORE YOU GET EXCITED OR ANYTHING:

    Slenderman does NOT avoid obstacles or do any algorithmic pathfinding of any sort. He just finds a waypoint and moves towards it. I am trying to work towards a basic path system based on passable / not passable that will allow for finding and moving around obstacles, similar to A* but with much dirtier coding ;)
    -------------------------------------------------------------------------------------------------------------------------------------------
    Code (csharp):
    1. //- Roam whenever the player is not seen by SM, and the player is not facing SM
    2. //- Move towards the player whenever player is seen by SM (not necessarily the player seeing him back), and the player is not facing SM
    3. //- Teleport to a legal position within a maximum and minimum range when:
    4. ///--- A. SM moves outside of the maximum range
    5. //--- B. SM roams for a random amount of time without seeing the player
    6. //--- C. The player is facing him (but does not see him), a random amount of time has passed, and there is still a chance he will not teleport at all
    7.  
    8.  
    9.  
    10.  
    11.  
    12.  
    13.  
    14. #pragma strict
    15. var moveSpeed:float = 0.0;   // how fast slendy moves
    16. var maxRange:float = 0.0;   // the maximum range SM can be from the player without teleporting.
    17.  var timer:int = 0;  // a little timer for function timing.
    18. var wayPoints:GameObject[];  // an array that stores all the waypoints for pathfinding.
    19. var player: GameObject;   /// the player gameObject, used for targeting
    20.  var targetWaypoint: GameObject; // very important: the current waypoint marked for pathfinding.
    21. private var lastTarget:GameObject; // ignore this unless you really want to know what it does.
    22. var isMoving:boolean = false;    //checks if SM is moving. useful for determining whether to stay or roam.
    23.  
    24. var pointer: GameObject;  // the pointer object used for spotting the player. Make sure it is not too high or too low.
    25. var range:int = 0;  // the range at which Slenderman can spot a player
    26. var canSee:boolean = false;  // if Slenderman can see the player (not vice versa or anything)
    27. var scanInterval:int = 0;   // how often to scan for player distance
    28.  
    29. function Start () {
    30.  
    31. wayPoints = GameObject.FindGameObjectsWithTag("waypoint");    // find all the GO's and store them off the start.
    32.  
    33. FindRoamPath();   // get us off pathfinding something
    34. }
    35.  
    36. function Update () {
    37.  
    38.  
    39. ////the eye of the Slenderman//////////////////////////////
    40. ///////////////////you can use your own SM vision code here.
    41. ///////////////////just make sure canSee is true for proper movement.
    42. pointer.transform.LookAt(player.transform);
    43. if (Physics.Raycast(pointer.transform.position,pointer.transform.forward,hit,range))
    44.     {
    45.         if (hit.collider.gameObject.tag == "Player")
    46.             {
    47.     Debug.DrawRay(pointer.transform.position,pointer.transform.forward,Color.red);
    48.         print(" can see!");
    49.         canSee = true;
    50.             }
    51.         else
    52.             {
    53.             canSee = false;
    54.             }
    55.  
    56. }
    57. else if (!Physics.Raycast(pointer.transform.position,pointer.transform.forward,hit,range))
    58.     {
    59.     canSee = false;
    60.     }
    61. ///////////////////////////////////////////////////////////////////////////////////////////////
    62.  
    63. /////////////////a private timer. can be replaced with Time function for more accurate results.
    64. ////////////////////after a certain amount of time, search distance to player.
    65. ////////////////////the only reason this is set up as a function is because of performance reasons / teleport function
    66. timer++;
    67. if (timer > scanInterval)
    68.     {
    69.         searchDistanceToPlayer();
    70.        
    71.         timer = 0;
    72.     }
    73.    
    74.    
    75.     //search for new waypoint once I'm close to one.
    76. if (Vector3.Distance(transform.position,targetWaypoint.transform.position) < 1)  // this number can be changed on whatevs (depending on scale);
    77.         {
    78.             if (!canSee)  //if I can't see the player. Just to make sure I'm actually roaming.
    79.                 {
    80.             FindRoamPath();
    81.                }
    82.         }
    83.    
    84.            
    85. if (isMoving)    //this does the actual movement.  movement is always the same, the target is what's different.
    86.     {
    87. transform.position = Vector3.MoveTowards(transform.position,targetWaypoint.transform.position,moveSpeed * Time.deltaTime);
    88.     }
    89.    
    90.    
    91. // If I can see the player, execute the function that finds a path to the the player
    92. // this is called everyframe because of SM visibility. a quick conditional will allow me to see if I can see the player (no pun intended)
    93. // if I can see him, then execute FindFollowPath(), which finds the nearest waypoint to the player (as if he is following him).
    94. if (canSee)
    95.     {
    96.         var nearpoint = FindFollowPath();
    97.         if (lastTarget != nearpoint)            //if it's not the same, then keep on moving
    98.             {
    99.         targetWaypoint = nearpoint.gameObject;
    100.         lastTarget = nearpoint.gameObject; // prevents re-moving to same position - jittery
    101.             }
    102.             else
    103.             {
    104.             isMoving = false;     //you're close enough, stop moving. This works by checking if the same waypoint has been selected twice.
    105.             }
    106.     }
    107.  
    108. }
    109.  
    110. function FindRoamPath()   //this doesn't do pathfinding. This just tells us the path to find. In this case, a random one.
    111.     {
    112.         isMoving = true;   // gotta get up off our feet
    113.         var rand:int = Mathf.Floor(Random.Range(0,wayPoints.length));   // a random waypoint has been selected!
    114.         if (lastTarget != wayPoints[rand])  // similar to above. don't randomly pick the same spot.
    115.                 {
    116.                     targetWaypoint = wayPoints[rand]; // our target waypoint is now a random one from the list.
    117.                     lastTarget = wayPoints[rand];
    118.                 }
    119.                 else
    120.                 {
    121.                 isMoving = false;
    122.                 }
    123.     }
    124.  
    125. function FindFollowPath() : Transform   //if I see the player, find a path to his position.
    126.     {
    127.     // loop through each tagged object, remembering nearest one found. Original "find nearest" code by Ben Pitt.
    128.     //http://answers.unity3d.com/questions/16676/how-can-i-make-my-gameobject-find-the-nearest-obje.html
    129.     // basically what it does is go through the list of waypoints and finds the nearest one to the -player- through distance.
    130.      var nearestDistanceSqr = Mathf.Infinity;
    131.     var nearestObj : Transform = null;
    132.    
    133.     for (var obj : GameObject in wayPoints) {
    134.  
    135.         var objectPos = obj.transform.position;
    136.         var distanceSqr = (objectPos - player.transform.position).sqrMagnitude;
    137.  
    138.         if (distanceSqr < nearestDistanceSqr) {
    139.             nearestObj = obj.transform;
    140.             nearestDistanceSqr = distanceSqr;
    141.         }
    142.     }
    143.  
    144.     return nearestObj;
    145. }
    146.    
    147.    
    148.    
    149.    
    150. function Teleport()    // take me to a random waypoint!   this function does not yet utilize legal (nearby) waypoints
    151.     {
    152.         var rand:int = Mathf.Floor(Random.Range(0,wayPoints.length));
    153.         targetWaypoint = wayPoints[rand];  
    154.         transform.position = wayPoints[rand].transform.position;
    155.     }
    156.    
    157.    
    158. function searchDistanceToPlayer()   // find distance to player. Might as well check if I'm above range to teleport, too.
    159. {
    160. var curDistance:float;
    161. curDistance = Vector3.Distance(transform.position,player.transform.position);
    162. if (curDistance > maxRange)
    163.         {
    164.             Teleport();
    165.         }
    166.  
    167. }
    I kind of got carried away, and in doing so sort of created a more general purpose AI, missing on the SM specific functionality! Never fear though, the next version of this script is coming soon. Here is the checklist:
    COMPLETED
    DONE
    ** DONE
    INCOMPLETE, SIMPLE ENOUGH
    SOME MORE WORK NEEDED HERE
    -------------------------------------------------------------------------------------------------------------------------------------------

    FURTHER IMPROVEMENTS FOR FUTURE PLANS:

    - Automatic waypoint generation system in the works. So easy! (if coded dirty that is!)

    - Terrain worthy (this should actually already work, if waypoints are placed via raycast from automatic generation)

    ----------------------------------------------------------------------------------------------------------------------------------
    if you have any questions please ask.

    directions for use:
    1.) assign to Slenderman object.
    2.) assign pointer object, or just Slendy himself
    3.) set move speed, make sure isMoving is checked at the beginning
    4.) make sure scanInterval is above 0, mine is set at 50.
    Last edited: May 25, 2012
  35. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    I've written some music to go with it now. It's a simple theme with four short loops (each loopadds an extra instrument). Nothing plays when no pages have been collected. When one page has been collected, it plays the first loop, then every two pages after that it changes to the next loop. Presumably on page 8, the game has been won, so it'll fade the music back out at that time.
    Last edited: May 25, 2012
  36. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    I'm experimenting with the terrain editor. It looks fairly easy to use, although I know I did something wrong because none of the trees are solid. Thankfully I was experimenting in a separate project, which saved me from a bunch of cleanup.
  37. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    I'm doing some research into scresn effects. Apparently, UnityFree does not support these kinds of effects directly like UnityPro does, so a workaround is to attach a plane in front of the camera and apply the effects to the plane instead.

    I'm also looking into footstep sound effects. This should be considerably easier.
  38. ludiares

    ludiares

    Member

    Joined:
    Jul 14, 2011
    Messages:
    220
    If you want the trees to collide, you have to put a capsule collider to the tree prefab
  39. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    Got another video. This one shows me picking up pages and the four music loops each starting. After that, I show the static effect that I apply to the screen when your sanity starts to drop.



    The static isn't really done justice by the video; it rendered it all wobbly-looking, but it actually looks more like regular static.
  40. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    I've made the textures for the pages now (linked due to size, they're each just over 1mb):

    Page 1
    Page 2
    Page 3
    Page 4
    Page 5
    Page 6
    Page 7
    Page 8

    Drew these myself to resemble the kind of scrawlings you find in the Slender Man mythos. I'm rather pleased with how they came out. ^^
  41. xxxDjdogxxx

    xxxDjdogxxx

    Member

    Joined:
    Mar 28, 2011
    Messages:
    751
    Last edited: May 28, 2012
  42. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    I appreciate it, but someone has already volunteered to make a SM model, and is currently working on texturing it. Plus, I'm going with the non-tentacled version of SM for this.
  43. xxxDjdogxxx

    xxxDjdogxxx

    Member

    Joined:
    Mar 28, 2011
    Messages:
    751
    okk it's fine just a really cool game concept :)
  44. Zethariel1

    Zethariel1

    New Member

    Joined:
    Mar 21, 2012
    Messages:
    439
    Holy, this game raises hair even without proper graphics... Really nice job with the sound effects!
  45. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    I've run into a few minor problems. There's a clipping issue with the FPS controller if you're running in widescreen, where you can see through the wall on the far right or left side if you're pressed up against it. I think I can probably fix it by making the object a little bigger, though I'm worried about making the player too big to fit around the map comfortably. My static object also clips a little, which I can try to fix by just making it smaller and placing it nearer to the camera.

    Another thing is that the static object gets squished when crouching (since everything on the player model gets squished). I was thinking about just taking out crouching entirely, since I'm not having jumping either. Simplified controls can be good, after all, and I honestly don't see a lot of need for crouching in this game to begin with.

    I applied my page textures to the pages, and I also figured out how to make them highlight (as if under full lighting) when you are able to pick them up.

    Next I have to figure out how to do the player's footsteps, and some kind of panting when stamina is low. That, besides any ambient sounds in the woods, will pretty much wrap up all of the games' sounds.
  46. ludiares

    ludiares

    Member

    Joined:
    Jul 14, 2011
    Messages:
    220
    Maybe, your problem with the camera seeing through objects can be solved by setting the camera Near Clipping Plane property to 0 instead of 0.3.
  47. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    That did it! Thanks!

    *EDIT* Although now, suddenly it doesn't let me pick up pages anymore if I'm too close...

    *EDIT EDIT* Okay, I set it to 0.2 instead, now it picks up the pages and the rendering issue still does not occur. Don't know why it affected the pages exactly, but as long as it works... :)
    Last edited: May 28, 2012
  48. AgentParsec

    AgentParsec

    Member

    Joined:
    May 5, 2012
    Messages:
    311
    Why I'm doing this instead of going to sleep, I don't know, but I have successfully put in the sound of footsteps and heavy breathing if you sprint for too long. Sounds are pretty much done at this point, though I will probably replace the dramatic sound that plays when SM is revealed within 10 meters. Okay, NOW I'm going to sleep.
  49. TehWut

    TehWut

    Member

    Joined:
    Jun 18, 2011
    Messages:
    1,579
    You could consider using this a screen effect for sanity meter, and I imagine it would work similar to a "blood effect" in other games.

    On the edges of the screen you would begin to see these vein like / tentacle like shapes. I always think through my ideas, and it would do a few cool things.
    1.) relate to that Eastern European SM mythos, a poem about how you will begin to see tentacles in the corners of your eyes
    2.) put the player on edge because it could look like SM is at the edges of your screen

    Of course, it would be much better drawn than this, just an idea.
    [​IMG]
  50. ludiares

    ludiares

    Member

    Joined:
    Jul 14, 2011
    Messages:
    220
    Awesome idea, little pony