Search Unity

Free Basic FPS Horror Type Package

Discussion in 'Assets and Asset Store' started by MadToLove, Sep 23, 2012.

  1. MadToLove

    MadToLove

    Joined:
    Jul 22, 2012
    Posts:
    70
    I have no plans to do so as of now, but maybe someone can pick up the mantle of that and make FPS HORROR starter kit for mobile. I have my own personal project I am working on as well. Perhaps if nothing crops up by then I will!
     
  2. TheRealFuzz

    TheRealFuzz

    Joined:
    Jul 17, 2012
    Posts:
    308
    Hey I downloaded this and it looks great except I can't run it because it has a few errors like this Assets/_Scripts/Flashlight/Flashlight.cs(4,14): error CS0101: The namespace `global::' already contains a definition for `Flashlight'

    Bear in mind that I'm not a coder so I don't really know what that is.
     
  3. The_Archives

    The_Archives

    Joined:
    Jan 1, 2013
    Posts:
    7
    The error you are receiving is caused by multiple copies of the same scripts loaded under Assets in Unity. To correct this delete any duplicates not found under the Scripts folder or it's sub folders. For example. _Door is located under assets and under the scripts folder. _Flashlight can be found in both standard assets and the scripts folder. If i recall there is one more I had to trash but can't remember it's location. Once the duplicates are removed you should be able to play the demo without errors. However be sure that you replace any missing scripts on the correct game objects.

    I hope this helps you. I am sure that MadToLove will reload a correct copy when he sees this. All in all a good package not only for a horror based game but for an adventure based one as well. Thanks for the hard work. I have been using Unity for a few months now and I liked what you have done that I actually decided to take a break and post something.
     
  4. TheRealFuzz

    TheRealFuzz

    Joined:
    Jul 17, 2012
    Posts:
    308
    @ Hventures Thanks so much! I'll try it out and see if I can fix it :)

    Edit: Okay so I got it to play but I can't pick up the torch/flashlight but I can open the doors, read the notes, pick up the key and listen to the audio box.
     
    Last edited: Jan 2, 2013
  5. The_Archives

    The_Archives

    Joined:
    Jan 1, 2013
    Posts:
    7
    The issue is that the capsule collider set on the FLASHLIGHT is not large enough to trigger the script. To fix this click on FLASHLIGHT under the hierarchy view then under the inspector change the collider size to 5 which should be large enough to get the code to work. Basically the way the code works it it attaches a light to the head of the FPS Character and can be toggled with the F key. I highly suggest watching the you tube videos written by Reality Flux Studios for more information. Even if you are not a coder they are worth you time to understand the basics. I linked the playlist below.

    http://www.youtube.com/playlist?list=PLB21B6E365F8A37EC
     
  6. TheRealFuzz

    TheRealFuzz

    Joined:
    Jul 17, 2012
    Posts:
    308
    Thanks for the help Hventures, I'll be sure to check out the videos. I think I might just wait until the next update because I don't quite understand why there are duplicates of lots of the scripts. I've got everything to work except the flashlight, none of the scripts I use work and the test game quits when I pick it up. It's confusing to know which of the scripts to delete.

    Thanks for the help though!
     
  7. The_Archives

    The_Archives

    Joined:
    Jan 1, 2013
    Posts:
    7
    Special Thanks to Aldo Naletto for his Unity Answer. I found this little gem at

    http://answers.unity3d.com/questions/164638/how-to-make-the-fps-character-controller-run-and-c.html

    All praise goes to him.

    The only thing I did was modify the script to be the Left Ctrl button to crouch. You can map it to anything you want by a simple altering of the code and looking up the key value on the unity resource page. Drag and drop the JS onto the FPS Controller then change the speed of run walk and crouch in the Inspector Window.

    Code (csharp):
    1. #pragma strict
    2.  
    3. var walkSpeed: float = 7; // regular speed
    4. var crchSpeed: float = 3; // crouching speed
    5. var runSpeed: float = 20; // run speed
    6.  
    7. private var chMotor: CharacterMotor;
    8. private var ch: CharacterController;
    9. private var tr: Transform;
    10. private var height: float; // initial height
    11.  
    12. function Start(){
    13.     chMotor = GetComponent(CharacterMotor);
    14.     tr = transform;
    15.     ch = GetComponent(CharacterController);
    16.     height = ch.height;
    17. }
    18.  
    19. function Update(){
    20.  
    21.     var h = height;
    22.     var speed = walkSpeed;
    23.    
    24.     if (ch.isGrounded  Input.GetKey("left shift") || Input.GetKey("right shift")){
    25.         speed = runSpeed;
    26.     }
    27.     if (Input.GetKey("left ctrl")){ // press left control
    28.         h = 0.5 * height;
    29.         speed = crchSpeed; // slow down when crouching
    30.     }
    31.     chMotor.movement.maxForwardSpeed = speed; // set max speed
    32.     var lastHeight = ch.height; // crouch/stand up smoothly
    33.     ch.height = Mathf.Lerp(ch.height, h, 5*Time.deltaTime);
    34.     tr.position.y += (ch.height-lastHeight)/2; // fix vertical position
    35. }
     
  8. The_Archives

    The_Archives

    Joined:
    Jan 1, 2013
    Posts:
    7
    No worries. I needed a break from a project I am working on and have always had a soft spot for horror games. So it's a nice change of atmosphere.
     
  9. TheRealFuzz

    TheRealFuzz

    Joined:
    Jul 17, 2012
    Posts:
    308
    Well I appreciate it so thank you. I got the flashlight to work but it doesn't show any of the HUD effects which I assume it's supposed to but at least I'm making some progress and learning.
     
  10. The_Archives

    The_Archives

    Joined:
    Jan 1, 2013
    Posts:
    7
    Hey guys, a couple of things I have done on my end and some useful information.

    In Unity 4.0 under ( project settings-->player ) you can assign a custom mouse cursor. I thought this was good information for when an inventory system would be implemented. However based on the current script set up the mouse cursor was being changed multiple time already. In order to resolve this I made some of the following changes and wanted to post them for your critique.


    1. I found a C# Cross hair script that I used to create a GUI Element in the middle of the screen.. In order for this to take away from the horror purpose behind the mod I went into gimp and created a small white dot that I called Pointer. I then assigned it as my default.

    The c# pointer code is below. Simply assign the code to an empty game object below the floor. I named mine GUI after some inspiration form the UNITY FPS tutorial. I though that would be a good base for creating any other HUD / inventory systems as well. I found the answer and credit goes where it is due. http://answers.unity3d.com/questions/201103/c-crosshair.html

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Pointer : MonoBehaviour {
    5.    
    6.     public Texture2D pointerStatic;
    7.    
    8.         void OnGUI(){
    9.        
    10.         float xMin = (Screen.width / 2) - (pointerStatic.width / 2);
    11.         float yMin = (Screen.height / 2) - (pointerStatic.height / 2);
    12.         GUI.DrawTexture(new Rect(xMin, yMin, pointerStatic.width, pointerStatic.height), pointerStatic);
    13.        
    14.     }
    15.        
    16.        
    17.  
    18. }

    2. Now for the fun part. Since the cursor was no longer needed for basic positioning I started in on the mouse over scripts. What bothered me initially was that if you moused over an object, even if it was far away you received the pop up cursor. This was a dead give away that something was there and wanted to be looked at. The second problem, for me at least, was the fact that we had two scripts that both pulled from the OnMouseEnter method. So my goal was to combine both scripts as C# so that one script was all that was needed to be attached. The script would handle the operation both scripts previously did withe the following adjustments.
    1. A check would be done on mouse enter to get the distance from the player. The distance could be adjusted in the inspector menu for ease of use.
    2. if the player was close enough then both the tool tip and the new pointer would be displayed.
    3. on mouse exit the pointer would revert to default and the tooltip would vanish.
    4. The mouse cursor would no longer be used for these functions.

    Adjustments Needed.

    To get it to work as intended the distance needs to be adjusted to match the looting code for the notes and the key. This is a minor adjustment and handled easily by the user.

    So basically two scripts for the price of one and add in some distance checking to round off the day.

    If I get around to it I will dig into the existing door script and notes script to see what other changes can be made to stream line it. Or if someone else wants to I have commented the basic code below for ease of use. I highly suggest reading the forum post on highlighting since it inspired me. Also the Unity documents on raycasting and any code you can get your hands on for that and creating gui elements.

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PointerChange : MonoBehaviour {
    5.     //variables for text
    6.     public string Text = "";
    7.    
    8.     private string currentText = "";
    9.    
    10.     private GUIStyle styleForeground;
    11.    
    12.     private GUIStyle styleBackground;
    13.    
    14.    
    15.    
    16.     //Variables for pointer
    17.     GUITexture pointerStatic;
    18.    
    19.     public Texture2D pointerPickup;
    20.    
    21.     public float interactiveDistance = 5f;
    22.    
    23.     private bool inRange = false;
    24.    
    25.    
    26.     void Start (){
    27.        
    28.         //start for text
    29.        
    30.         styleForeground = new GUIStyle();
    31.        
    32.         styleForeground.normal.textColor = Color.white;
    33.        
    34.         styleForeground.alignment = TextAnchor.UpperCenter;
    35.        
    36.         styleForeground.wordWrap = true;
    37.        
    38.         styleBackground = new GUIStyle();
    39.        
    40.         styleBackground.normal.textColor = Color.black;
    41.        
    42.         styleBackground.alignment = TextAnchor.UpperCenter;
    43.        
    44.         styleBackground.wordWrap = true;
    45.        
    46.         //start for pointer
    47.        
    48.         pointerStatic = (GUITexture) GameObject.Find("GUI").GetComponent(typeof(GUITexture)); // Finds a gameObject named "GUI" and gets its component GUITexture
    49.     }
    50.        
    51.     // Update is called once per frame
    52.     void OnMouseEnter () {
    53.    
    54.     // Getting distance for use
    55.     RaycastHit hit;
    56.        
    57.             if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, interactiveDistance)){
    58.            
    59.             Debug.Log (hit.collider.gameObject.name);
    60.            
    61.             inRange = true;
    62.  
    63.     //current text
    64.             currentText = Text;
    65.            
    66.            
    67.         }
    68.     }
    69.        
    70.         void OnGUI() {
    71.        
    72.         if(inRange) {
    73.         //if in range change crosshairs
    74.         float xMin = (Screen.width / 2) - (pointerPickup.width / 2);
    75.         float yMin = (Screen.height / 2) - (pointerPickup.height / 2);
    76.         GUI.DrawTexture(new Rect(xMin, yMin, pointerPickup.width, pointerPickup.height), pointerPickup);
    77.            
    78.         //display text
    79.         float x = Event.current.mousePosition.x;           
    80.         float y = Event.current.mousePosition.y;
    81.         GUI.Label (new Rect (x-149,y+40, 300,60), currentText, styleBackground);
    82.         GUI.Label (new Rect (x-150,y+40, 300,60), currentText, styleForeground);
    83.         }
    84.            
    85.     }
    86.    
    87.     void OnMouseExit (){
    88.        
    89.             inRange = false;   
    90.            
    91.     }
    92.                        
    93. }
    94.  
    Anyway there you go. Use it if you wish.
     
  11. The_Archives

    The_Archives

    Joined:
    Jan 1, 2013
    Posts:
    7
    Ignore this. The problem was lack of sleep and using an older build.
     
    Last edited: Jan 3, 2013
  12. MadToLove

    MadToLove

    Joined:
    Jul 22, 2012
    Posts:
    70
    Thanks for all the help Hventures! Appreciate it. I will upload a fixed version of the files as soon as I have the time, been super busy with my personal project and just the ole 9-5 grind we all wish we could escape. I am not ignoring this project just been very busy. Thanks all for your patience and support. One thing though, likely will be seeing less updates coming out for this if any from here on out as I am now using Playmaker for my scripting, since my scripting knowledge is limited and so are my funds and time I just needed a visual scripting tool to really help me out. I have already made leaps and bounds as far as making working elements for my personal game now. If any of you have trouble with coding or scripting I HIGHLY recommend checking out Playmaker asset on the asset store. The community is great, the price is right for what you get and there is lots of support. Sorry about all this but honestly I cannot spend all my time searching forums, trying to find coders to help me or paying people to write scripts for me any longer and it was really putting a dent into me making real progress on my personal project. I hope you all understand. But as always if i stumble upon any great scripts or things that I can add to this I always will do so. But it will be less likely and less frequent now that the majority of my coding is being done via Playmaker now.

    EXAMPLE: in 20 min I was able to recreate the Note pickup script via Playmaker and add other features to it, such as blurring of the background when reading it, it playing a paper sound as you pick it up and discard it, locking the mouse movement and player movement while reading a note. And also was able to in a hour work out a good health/sanity system that had dynamic effects on the gameplay as you move forward. So as I said, if your not great at coding or even complete poopoo at coding like myself, check out Playmaker its worth the investment and it coupled with NGUI asset on the asset store can really help us creative types that dont have alot of coding skills make a awesome, playable and beautiful game in less time then ever. It has really changed my whole perspective on making my personal game project come to life. You can see some more details here on my personal project and some of the things I am now able to do using Playmaker. http://www.youtube.com/playlist?list=PLwc2jb3IjPt7zsCHADQdyHoR9p6WQV0V9&feature=view_all
     
  13. haydeyho

    haydeyho

    Joined:
    Feb 26, 2013
    Posts:
    1
    When I opened it i got 8 errors plz help
     
  14. TheRealFuzz

    TheRealFuzz

    Joined:
    Jul 17, 2012
    Posts:
    308
    Hey guys, anyone still working on this?
     
  15. hike1

    hike1

    Joined:
    Sep 6, 2009
    Posts:
    401
    Anyone know how to change the OpenableDoor script to just open and close without a key?
     
  16. Julian_Spring

    Julian_Spring

    Joined:
    Mar 5, 2013
    Posts:
    2
    What do you think about an Inventory system like in amnesia/penumbra?

    Grid and click type system. Just a thought.
     
  17. awesomeaustin316

    awesomeaustin316

    Joined:
    Jun 6, 2012
    Posts:
    21
    Guys than you so much for such an amazing free starter kit. However I'm having trouble picking up the key. I deleted all Duplicates, is there any scripts I need to add or am I just not pressing the right button ? The key is the only thing that isn't working and I'm getting no errors

    EDIT
    Actually it let me use it AFTER i clicked on the door.