Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8936551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:14:21+00:00 2026-06-15T10:14:21+00:00

I am trying to go through a tutorial on Unity (Will Goldstone’s book 3.x

  • 0

I am trying to go through a tutorial on Unity (Will Goldstone’s book 3.x Game Development Essentials) and keep running into an error messages and I just can’t figure out what is wrong with my code. It’s from Chapter 5, I am writing this in Javascript. For what i can see I have everything correct–the null reference comes up in my OpenDoor function line 2 & in my shutDoor function line2.:

Null Reference Exception
PlayerCollisionsjs.OpenDoor(UnityEngine.GameObject door) (at Assests/Scripts
/PlayerCollisionsjs.js: 47 **and 37 the lines refecenced below).

What am I missing? My OpenDoor & CloseDoor sounds are loaded and the code works if I remove the shut Door requests…any thought

#pragma strict

private var doorIsOpen : boolean = false;
private var doorTimer : float = 0.0;
private var currentDoor : GameObject;


var doorOpenTime : float = 3.0;
var doorOpenSound : AudioClip;
var doorShutSound : AudioClip;

function Start () {

}

 function Update () {

    if(doorIsOpen) { doorTimer += Time.deltaTime;
    if(doorTimer > doorOpenTime) {
        shutDoor(currentDoor);
        doorTimer = 0.0f;
      }
    }
 }

function OnControllerColliderHit(hit : ControllerColliderHit){

        if(hit.gameObject.tag == "playerDoor" && doorIsOpen == false) {
        currentDoor == hit.gameObject;
        OpenDoor(hit.gameObject);
        OpenDoor(currentDoor);
      }

  }

function OpenDoor(door: GameObject) {

    doorIsOpen = true;
    door.audio.PlayOneShot(doorOpenSound);
    door.transform.parent.animation.Play("dooropen");   
}


function shutDoor(door : GameObject) {

    doorIsOpen = false;
    door.audio.PlayOneShot(doorShutSound);
    door.transform.parent.animation.Play("doorshut");
}

I did see that someone else got stuck on the same code, but we don’t have the same problem, my audio works before I insert the shutDoor function.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:14:22+00:00Added an answer on June 15, 2026 at 10:14 am

    I think you did not assign open and shut door sounds to above two audio clips, 1st assign these sounds to your variables then your error will be finished.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to work my way through an Objective-C tutorial. In the book there
I've been running through the ASP.Net MVC C# Movie Database tutorial, but been trying
Possible Duplicate: Can't convert String into integer in ruby/ruby-on-rails I'm running through a tutorial
Hi guys I'm running through this tutorial: http://www.sencha.com/learn/a-sencha-touch-mvc-application-with-phonegap and trying to get the code
I'm trying to go through Hibernate tutorial and got stuck on running the command
I've been trying to work through a tutorial which I foresee will be very
I was trying to go through the tutorial nodetuts.com - tutorial 2 and unfortunatly
Trying to learn a bit about PDO and is going through this tutorial .
I am working through this tutorial https://developers.google.com/cloud-print/docs/android for google cloud print. I am trying
I'm trying to run through the Hello World tutorial for the iPhone and i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.