New to the forums ( new to javascript too, sorry about that)

Hey guys, i just found started programing with unity, but i been trying to develop games as a hobbie for like… ten years or such… with antique tools like rpg maker, reality factory , flash etc… but i realy think Unity is the one, is the most complete and adequated game developing tool i set my hands on, to think people use this software to make comercial games for wii, iphone etc… its a real big deal

oh well i got carried away, what i actualy wanted to ask is… can one script “activate” another script?

i mean… im doing a pause game menu… when i pause the game ( set timescale to zero ) everthing pauses… i got that part…

but after that the only thing that responds to comands its the unpause script, because all the rest is desativacted and just does not move

my plan was to do a script that would show a menu with gui textures on the screen after the game is paused, and a script that answers to keyboard comands to navigate trough the menu

can someone give me a tip? theres any code i need to use so my scripts work even when timescale is zero?

You can use a script’s “enabled” property to have it stop firing Unity events (such as Update). Use GetComponent to get the script, then just set enabled = false/true.

Not sure about a workaround with the timescale bit; I’ve never had to use it.

I seem to remember something about NOT setting timescale to zero—rather, a value very close to zero (0.00001). This prevents everything from stopping completely, and the continuing movement of time is negligible (about 1.15 days IRL per one game second). I’m assuming you have scripts for the GUI in place, they just aren’t working; or do you need help there too?

it worked!! IT WORKED!! yheaaa!!

thanks dannyL

and thanks fizix man too

well… about the gui pictures… yhea… i have some issues with that too but i dont wanna waste all my questions with this, i’ll save then

no better yet, i have a more important question if i may…

i cant mentionate a variable in a script… if it belongs to another script? evertime i try to do this i got an error msg… but… to me thats the only logic way to program some stuffs…

for example :

theres a script for jumping, and in that script theres a variable called “is jumping” so i set it to true when the character is on the air… ok

so i have another script, and is for double jumping… so right on the beging of the script i ask " IF " is jumping is true, then you can double jumpo

but then i got an error msg telling me that the script doest know that variable… just because its not metioned on the double jump script… BUT if i mention the var “is jumping” on the double jump script, im gonna have to set it to true or false… what defeats the whole porpurse of the “if”

gosh;… that sounded too complex… i dont think i cant express exactly the problem with this one , but its ok thanks for the help about the timescale!

Hello and welcome to unity. Never be afraid to ask any question, so long as you try to solve it yourself and search for it.

As for that, when you attach a script to a gameobject every variable outside of a function in that script becomes unique to that gameobject. Variables set up inside functions are local only to that function if you understand what I mean.
This lets you attach the same script to hundreds of objects, with each object having it’s own unique variable data.

So to get a variable from another game object’s script, this should help you.

This should work, rarely use them myself right now.

//var someScript : ExampleScript;
var someScript = GetComponent (ExampleScript);
someScript.function();
var f = someScript.variable;

In order for windexglow’s code example to work, the variables within the script you want to access needs to be public variables.

Yes, this is possible.

//var someScript : ExampleScript; // <-- uncomment and use this if you want to drag--drop the script to the variable in the editor inspector window
var someScript = GetComponent (ExampleScript); // <-- use this if you want to find the script through code, this may require more code
someScript.enabled = true; // <-- enables the script - use "false" to disable it!

Uscript has variables public by default, I doubt he’s into static yet.

[QUOTE=
Yes, this is possible.

//var someScript : ExampleScript; // <-- uncomment and use this if you want to drag--drop the script to the variable in the editor inspector window
var someScript = GetComponent (ExampleScript); // <-- use this if you want to find the script through code, this may require more code
someScript.enabled = true; // <-- enables the script - use "false" to disable it!

[/QUOTE]

thats gold!!!

so with that… i can uncheck that litle box on the side of the script… so when the player first arrive at the map, that script will not be running… but then… i can trigger a collider or even set some key, so he can activate that script and boom!

there you have it scripts activating scripts! … IS GENIOUS!! ITS ALIVEEEE thunderstrikes

sorry is just that i get too excited when i actualy compreend the gears behind these stuffs… my first days using unity were frustrating xD

Oh and windexglow… that was one usefull information, thanks a bunch you made double jump possible, and thanks for undestanding exaclty what i was asking for because i realy tough nobody was going to folow all that…

this foruns rocks, i hope i can repay the favor when i get pro at javascript

Correct, you can deactivate the scripts in the inspector for the prefabs, and let them only activate when done through another script.

Glad to see that’s what you was looking for! :slight_smile:

hey! hm…

i realy dont want to create another topic to do such a dumb question so… im gonna ask here again (hope is not agains the rules… if it is, i’ll be knowing this now and never do it again, scouters word )

how do i make a dash comand?

now… wait, i think i’ll be ok if someone just expain me how to make my character moves fast in the direction he is facing

like… i know it has something to do with moveDirection.X right? and something about Vector3( variable of dashing ,0,0)

but i cant,., code it >.<

Take a look at my fly script
http://forum.unity3d.com/threads/67042-Fly-Cam-(simple-cam-script)

It’s not proper movement, but it has an example of “sprinting” by holding down shift key. It makes the camera move in the direction it’s facing as well.

Edit : For small questions like this use UnityAnswers
http://forum.unity3d.com/threads/34680-Unity-questions-need-UnityAnswers

Works very well, when I do use it I rarely get no answers.

realy thanks again man… i realy tried the whole day before coming here to ask again…

i was trying to addforce to the character… since he is a rigidbody … doing this:

function Update ()
{

if (Input.GetButtonDown (“RightDash”)) {

gameObject.Player.rigidbody.AddForce (transform.forward * 200);
}
}
@script RequireComponent(CharacterController)

but it kept giving me an error that could not find “Player” but i checked a lot of times if the name was spelled rifght and i even tried to tag him with the name Player but the script just didnt find him

well i wont be needing this script anymore, gonna check on yours man! thanks again , i’ll be using UnityAnswers from now on when i have problems like this.

I’m not sure what command you were looking for
gameObject.Player.rigidbody.

But when dealing with other game objects (that don’t change), I normally create a GameObject variable and select the correct one through the inspector (editor).
var Player : GameObject = null; //set up in Inspector

hm… so thats why is not finding … well what im exaclty trying to do is … to press and hold a button and the player will be launched forward as if he had a rocket propeler atached to him, y’know?

…hey… HEY! i think i got an idea now that i was talking to you… i’ll see if this works:

( just to not let anyone curious, the idea was :

var controller : CharacterController = GetComponent(CharacterController);
var forward = transform.TransformDirection(Vector3.forward);
var Dashing = false;

function Update () {
if (Input.GetButtonDown(“Dash”)) {
controller.SimpleMove(forward * 200);

Dashing = true;

}
}

else { Dashing = false; }

EDTI: yhea that didnt work :P… but im glad i learned about Move and Simplemove, this may be handy

Here’s an old post with some movement code I put together for a test build:
http://forum.unity3d.com/threads/41710-Camera-for-Sled-Game?p=265858&viewfull=1#post265858

Do check out the following posts in that thread. I would recommend using FixedUpdate() for physics based movement (i.e. applying gravity, addforce, etc.).

The CharacterController is based on physics.