Access Variable in a class from another script

Hi

im using the platform controller that comes with unity and im trying to change the speed of the player within the game. the problem is that the speed var is located with in a class in the Player script and im having trouble accessing it from another script.

its located: Controller then in a class called ControllerMovement then speed.

how do i get to the speed var from another script

Code would be very helpful :) Thanks

EDIT: this is where it is, inside LanganController

`#pragma strict

var canControl = true;

var spawnPoint : Transform;

class LangmanControllerMovement { // the class i cant access

var runSpeed = 7.0; // i want to change that Var from another script
`

and this is how i tried to change it from another script on another object :

`
// so you assign the player here in the inspector

var target :LangmanController;

function Update() {

var temp = target.GetComponent("LangmanControllerMovment";

temp.gravity = 100;

}

`

Thanks

There are two ways around it. Depenging on how and why you want to increase the players speed. If you are using a "pickup" and want the character to speed up when he collects it then add a variable to the part of script that controls speed saying something like

if (HasPickup)
{
   Speed = Speed * 1.5;
}

or if you really need to access it from another script make it a public or static variable depending on what method you want to access it with.

Also get component works like this:-

// so you assign the player here in the inspector
var PlayerObject : GameObject;
//get the component from the player, in this case a script
TemporaryVariable = PlayerObject.GetComponent(PlayerScriptWithSpeedOn);
//do something to the speed variable on that script
TemporaryVariable.Speed = TemporaryVariable.Speed * 1.5

You could take a look at the reference for GetComponent.

ITS ALL GOOD EVERYONE I FIGURED IT OUT I WAS CALLING THE WRONG THING I WAS MEANT TO BE CALLING MOVEMENT.SPEED NOT THE MOVEMENT CLASS . SPEED

I PROBS DONT MAKE ANY SENCE BUT IT DONT MATTER COZ IT WORKS :)

Let be your first script name called sample

with varibale

 var size : float = 10;

Let be your second script name called sample1

  GetComponent(sample);

function OnGUI()
  {

  sample.size = 20;

    }