Could someone help me with scripting a Trigger that when the player enters and then presses the E Key a new level is loaded. My script is JS at the moment.

#pragma strict

var newScene : String;

function OnTriggerStay()
{
if(Input.GetKeyDown(“E”)){
Application.LoadLevel (“Chapter1”);
}
}

Perhaps something like this is the simplest way I can think of doing it.

// attach to your player object
// the 'target' could be an empty cube gameobject that the player is inside of
var distance;
var target : Transform; 
var activedistance = 11; // how close to the cube the player has to be
    

function Update () {
    distance = Vector3.Distance(target.position, transform.position);
    if(distance < activedistance){
    if ( Input.GetKeyDown("e")) {
    doEkeystuff (); // stuff you want to happen when the e key is pressed
    }
    }
}


function doEkeystuff (){
// stuff in here which happens
Debug.Log("you are in range and pressed the E key");
}

A unity example file attached if helps[58498-insidecube.zip|58498]