this script works, when play, the sphere will start blinking. which is not what i wanted. i wanted it to blink when i Input.GetMouseButtonDown(0). i try to put the sphere_blink(); inside Input.GetMouseButtonDown(0). But it will on when first click and off 2nd click. which also wrong. what i wanted is when i Click, then the sphere start Blinking. some1 please help me check where should i change in my script. Thx
private var hitPos : Vector3 ;
private var hitObjectPos : Vector3 ;
private var hit : RaycastHit ;
private var Down : boolean = false;
private var blip : GameObject ; //<–sphere11
var timer : double ;
var onoff : boolean;
function Start(){
blip = GameObject.Find("Sphere11") ;
blip.renderer.enabled = false ;
}
function Update(){
sphere_blink();
if(Input.GetMouseButtonDown(0)){
Down = Input.GetMouseButtonDown(0);
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition) ;
blip.renderer.enabled = true ;
if(Physics.Raycast(ray , hit)){
hitPos = hit.point ;
hitObjectPos = hit.transform.position ;
}
}
}
function FixedUpdate(){
blip.transform.position = Vector3(hitPos.x , 5 , hitPos.z) ;
}
function OnGUI(){
//The world position of the ray's contact point->
if(Down == true){
GUI.Label(Rect(5,50,200,50),hitPos+ "") ;
}
}
function sphere_blink()
{
if (Time.time > timer)
{
timer = Time.time + .4;
onoff = !onoff;
blip.renderer.enabled = onoff;
}
}