- Home /
Mouse targeting error
Im trying to program my game so i can target a enemy by clicking on them but all its doing is cycling through them whenever i click the mouse button
if( Input.GetMouseButtonDown(0) ){
             TargetEnemy();
     }
} }
What can i add or alter so i can target my enemies by clicking on them i am programming using C# if you need me to post more of the script Just ask thanks in advance
Answer by TheGamer106 · Mar 19, 2012 at 10:42 AM
Hi, the problem with that is that Input.GetmouseButtonDown(xyz) is effectivly a global check.. So, when ever you click and what ever you click over, the code will execute. something more localised would be
 function OnMouseDown()
 {
     print("Enemy's been clicked!");
     TargetEnemy();
 }
Hope I helped --TG106
It really helped i was able to alter it and it brought me closer to my goal im still having a problem with targeting the exact target i want becuase it's cycling through my enemies ill post my entire script soon
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                