- Home /
true and false wont work!
Hello everyone, well it seems that unity wont reconise the words true and false. Is there anything that i can do to make unity reconise thoes words. I find ot pretty hard making a some sort of "dying" script without using true and false. I have tried reinstalling Unity but it is still the same. Please help me Thanks!
Can you please post your script? 'true' and 'false' should work fine. Have you written it all in lower-case?
Answer by alienx2 · Nov 14, 2010 at 01:42 PM
make sure use code "var : boolean = true;" before start type code...:)
example:
var ready : boolean = true;
function Start() { print("the answer is"+ ready); //See your console "the answer is true"
yield WaitForSeconds(1); //Take a break for 1 second
ready = false;
print("the answer is"+ ready); //See your console "the answer is false"
}
or in javascript, you could just do
var ImAlive = true; var ImDead = false;
No none of the suggestions helped but thanks!. One of my scripts look like this:
var IsQuitButton = false
function On$$anonymous$$ouseEnter () { //Change the color when mouse hovers over text.
renderer.material.color = Color.black;
}
function On$$anonymous$$ouseExit () { //Change the color of the text when mouse hovers away from text back to default.
renderer.material.color = Color.white;
}
it wont change the word false into a diffrent color and with out this i cant make a main menu.
your code should be var IsQuitButton : boolean = false;
yes agreed with boymeetsrobot... similar to look up example code :)
Answer by john-essy · Aug 02, 2011 at 02:53 PM
Answer by Jono 1 · Nov 29, 2010 at 06:26 AM
I am having the same problems can someone take this script and change it so u respawn when you press "r" to this location 0.0002233056,0.2736679,-3.468594 the bullit var is called fireBall the script is for a coco nut that can move and shoot the coco nut is called Sphere in the hierachy i wan't to respawn when the fireball hits me THANKS!
var speed = 3.0; var rotateSpeed = 3.0; var bullitPrefab:Transform;
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
if(Input.GetButtonDown("Jump"))
{
var bullit= Instantiate(bullitPrefab,GameObject.Find("SpawnPoint").transform.position,
Quaternion.identity);
bullit.rigidbody.AddForce(transform.forward * 2000);
}
}
@script RequireComponent(CharacterController)
Answer by denewbie · Nov 14, 2010 at 01:25 PM
Unity scripts do recognise true and false be it the mono or javascript.
If you're having some problems with your scripting maybe you could post some of it so we could help out more.
Your answer
Follow this Question
Related Questions
Why does this simple script not work????? 0 Answers
Image remain invisible but wanted it to become visible 0 Answers
True False What am I doing wrong. 1 Answer
True and False values with If and else 1 Answer
Boolean Uncheck Inspector if False 2 Answers