- Home /
Script static var, problems
Both A and B objects have got the same scirpt. If A object [or B object] goes to collision with another object, only B object will apply [transform.position -= Vector3(0, 2, 0); ]. A object will apply only [transform.Translate(Vector3.left speed Time.deltaTime); ]. Why? What's the reason? Can it be resolved? Thanks for your availability. All objects have the Box Collider component and Rigidbody. this is the code:
pragma strict
public static var varJ : boolean = true; public static var varK : boolean = false; var speed : int;
function Start () {
}
function Update () { movimento();
}
function movimento() {
if(varJ) { transform.Translate(Vector3.right speed Time.deltaTime);
}
else {
transform.Translate(Vector3.left speed Time.deltaTime);
}
if(varK) { transform.position -= Vector3(0, 2, 0); ciao = false;
}
}
function OnTriggerStay(col : Collider) {
if(col.gameObject.tag =="Untagged")
{
if(varJ)
{
varJ = false;
}
else
{
varJ = true;
}
varK = true;
} }
Please format your code using the 101010 button, or by indenting it four spaces.