multiple "if" variables

Can you have one "if" statement be true with more than one variable?

What i would like is for my rolling ball to grow if the variable "Grow" is true, and if it is moving. ( i aready have it so it must be touching the ground)

Here's my script:

var Grow = false;

`function OnCollisionStay(collisionInfo : Collision) { if (Grow){ transform.localScale += (Vector3(0.05,0.05,0.05)*Time.deltaTime); } }`

How can i make that script so it has to be moving by combing it with something similar to:

`if(rigidbody.velocity.magnitude > 0) { transform.localScale += (Vector3(0.05,0.05,0.05)*Time.deltaTime); } }`

3 Answers

3

Use the binary operator &&.

if (Grow && rigidbody.velocity.magnitude > 0)
{
    transform.localScale += Vector3(0.05f, 0.05f, 0.05f) * Time.deltaTime;
}

Ok, i figured it out.

if (Grow){
if (rigidbody.velocity.magnitude > 0){
    transform.localScale += (Vector3(0.05,0.05,0.05)*Time.deltaTime);
}

}

http://msdn.microsoft.com/en-us/library/2a723cdk(v=vs.71).aspx