Search Unity

help with jumpscare script

Discussion in 'Scripting' started by SgtBossGamer, Sep 23, 2014.

  1. SgtBossGamer

    SgtBossGamer

    Joined:
    Sep 22, 2014
    Posts:
    4
    I'm trying to make a horror game, so I looked for a tutorial on jumpscares. The script in the tutorial I found, worked in the video, but it doesnt work for me. What I want it to do is, when I walk into a box, I want an object to pop up with a screaming noise, but when I do it, the plane I am using with a face on it shows up, but without the face. here is the script...
     

    Attached Files:

  2. Jmanpie

    Jmanpie

    Joined:
    Oct 7, 2012
    Posts:
    132
    Use insert code instead of attaching the script. you will get help that way
     
  3. MrPriest

    MrPriest

    Joined:
    Mar 17, 2014
    Posts:
    202
    Well there could be a few reasons.
    1. Does the picture get affected by lighting? I'd assume the room or game in general is quite dark.
    2. Is it possible that the plane is backwards, or that the texture/picture rendering is off?
    3. Try to give it a constant "on" for one try, with a lit setting, to see if it's a rendering issue.
     
  4. SgtBossGamer

    SgtBossGamer

    Joined:
    Sep 22, 2014
    Posts:
    4
    It just started giving me an error message saying "Assets/scripts/trigger.js(49,1): BCE0044: expecting }, found ''."
    And I tested it without the script to see if the plane would show up with the picture, and it did.
     
  5. SgtBossGamer

    SgtBossGamer

    Joined:
    Sep 22, 2014
    Posts:
    4
    Code (JavaScript):
    1. var face : GameObject;
    2.  
    3. var hasplayed = false;
    4. var entertrigger = false;
    5.  
    6. var screamingsound : AudioClip;
    7.  
    8.  
    9.  
    10.  
    11. function Start () {
    12.  
    13.     entertrigger = false;
    14.     face.renderer.enabled = false;
    15.  
    16. }
    17.  
    18.  
    19. function OnTriggerEnter (other : Collider) {
    20.  
    21.     entertrigger = true;
    22. }
    23.  
    24. function Update () {
    25.  
    26.     if (entertrigger == true) {
    27.         face.renderer.enabled = true;
    28.         removeovertime ();
    29.         makehimscream ();
    30.    
    31.     }
    32.  
    33. }
    34.  
    35.  
    36.  
    37. function removeovertime () {
    38.     yield WaitForSeconds (0.1);
    39.     face.renderer.enabled = false;
    40. }
    41.  
    42.  
    43. function makehimscream () {
    44.     if (!hasplayed) {
    45.         hasplayed = true;
    46.         audio.PlayOneShot(screamingsound);
    47.  
    48. }


    There's the code
     
  6. SgtBossGamer

    SgtBossGamer

    Joined:
    Sep 22, 2014
    Posts:
    4
    I fixxed the error message by adding another bracket at the very end, but it still isn't doing what I want.