- Home /
Question by
malekbakeer · Jun 19, 2013 at 11:39 AM ·
functionifcall
{ ERROR } call a function from other script
hi i need to call a function from a script named with CubeComplete from a script named with wall so this is the wall script
var endPoint : Vector3;
var duration : float = 1.0;
var CubeComplete : Component;
private var startPoint : Vector3;
private var startTime : float;
function Start() {
startPoint = transform.position;
startTime = Time.time;
CubeComplete = (CubeComplete).GetComponent(typeof(CubeComplete));
}
function OnMouseOver()
{
if(Input.GetMouseButtonDown(0))
{
CubeComplete.on();
transform.position = Vector3.Lerp(startPoint, endPoint, (Time.time - startTime) / duration);
}
}
and this is the CubeComplete script
public var touchCount : int;
var on : boolean;
var off : boolean;
function OnCollisionStay (collision : Collision) {
touchCount = touchCount + 1;
if (touchCount == 4)
renderer.enabled = false;
}
function OnCollisionExit (collision : Collision) {
touchCount = touchCount - 1;
if (touchCount == 0)
renderer.enabled = true;
}
function onoff () {
if (on == true)
collider.enabled = true;
yield new WaitForSeconds(2.3f);
collider.enabled = false;
if (off == false)
collider.enabled = false;
}
and i want to call this
if (on == true)
collider.enabled = true;
yield new WaitForSeconds(2.3f);
collider.enabled = false;
Comment