- Home /
 
               Question by 
               kobebeef415 · Jul 07, 2013 at 01:41 PM · 
                javascriptvariablevariablesvar  
              
 
              One of my scripts can't find the variable from this script
I want to know how to get my variable(walkSpeed) to work on another script
pragma strict
function Start () {
}
function Update () {
var maxWalkSpeed = 10.0;
var maxTurnSpeed = 100.0;
// Get the horizontal and vertical axis. // By default they are mapped to the arrow keys. // The value is in the range -1 to 1
 var walkSpeed = Input.GetAxis ("Vertical") * maxWalkSpeed;
 var turnSpeed = Input.GetAxis ("Horizontal") * maxTurnSpeed;
 // Move translation along the object's z-axis
 transform.Translate (0, 0, walkSpeed * Time.deltaTime);
 // Rotate around our y-axis
 transform.Rotate (0, turnSpeed * Time.deltaTime, 0);
}
               Comment
              
 
               
              Answer by supercouge · Jul 07, 2013 at 01:44 PM
Take a look at this answer: http://answers.unity3d.com/questions/50466/get-variables-from-other-scripts.html
Edit : In your case, declare walkSpeed outside of the Update() function.
can you give me an example of making it seen by others? like declaring it outside of update function. i'm new to this it's my first script that I'm making
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                