Help me! Please!!!

Okay, so I’m making this FPS game but you don’t start out with any guns. Instead you walk up to a turret and shoot all the zombies. But I have no idea what to say in the script for the character to walk up to the turret and ‘enter’ it! I would like the player to push the space bar to enter it, and to exit it. PLEASE HELP!!! thank you. I’m a total noob when it comes to scripting. :frowning:

See:

function Update () {
if (Input.GetButton (“Space”))
enter browning
}

This is what my game looks like so far (still adding things)

Is that a link to a file on your hard drive?

facepalm

Anyhoo, this right here is a very ineffecient bit of code, but it should help give you at least one idea of how to go about this.

Player.js
static var instance : Player = null;
var maxDistToEnterTurret : float;

function Start() {
  if ( instance != null ) throw ("Two active Player objects!")
  instance = this;
}

function Update () {
  if ( Input.GetKeyDown( KeyCode.Space ) ) {
    var allTurrets : Array = GameObject.FindObjectsOfType( Turret );
    var closest : Turret;
    var closeness : float = maxDistToEnterTurret;
    for ( var t : Turret in allTurrets ) {
      var d : float = Vector3.Distance( transform.position, t.transform.position );
      if ( d <= closeness ) {
        closest = t;
        closeness = d;
      }
    }
    if ( closest ) {
      this.enabled = false;
      closest.Control();
    }
  }
  // other player controls go here
}
Turret.js

function Control() {
  var control : boolean = true;
  while ( control ) {
    if ( Input.GetKeyDown( KeyCode.Space ) ) {
      Player.instance.enabled = true;
      control = false;
    }
    // other turret controls go here
    yield;
  }
}

You might do well to go through the various tutorials and resources here:
http://unity3d.com/support/resources/

THANK YOU!
But I still have problems. And am I supposed to be able to walk up to the turret and push the “space” button to enter?
Then again thank you for your help.

Bigger picture: Photo Storage

Hey just wanted to let you know, you can just change ur forum html code to make it so u click on image to make it bigger. Just type it like this:

[plain][/plain]