ACTIVATE_SONAR issue

Posted By: uone

ACTIVATE_SONAR issue - 07/09/09 05:57

How can i deactivate "ACTIVATE_SONAR" in c_move function in a certain time like after wait(-1)? is there any other way? please advise...
Posted By: Germanunkol

Re: ACTIVATE_SONAR issue - 07/09/09 07:46

you need to use two different c_move instructions. One with ACTIVATE_SONAR and one without. like this:


Code:
var use_sonar = ON;
while(1)
{
   if(use_sonar == ON)
   {
      c_move(my, vector(time_step,0,0),ACTIIVATE_SONAR|IGNORE_PASSABLE);
   }
   else
   {
      c_move(my, vector(time_step,0,0),IGNORE_PASSABLE);
   }
   wait(1);
}



now use a function to switch use_sonar on and off, and there you go.
Is that what you mean?
Posted By: uone

Re: ACTIVATE_SONAR issue - 07/09/09 09:24

yeah! thanks man it works now.
i also make a time_passed var to turn "var use_sonar = ON;" to OFF

here is my code:

var use_sonar = ON;
var time_passed = 0.3; // the loop will run for 0.3 seconds

while (1)

{
time_passed -= time_step / 16;

if(use_sonar == ON)
{

c_move(me,vector(30*time_step,0,0),nullvector,IGNORE_PASSABLE | GLIDE | IGNORE_FLAG2 | ACTIVATE_PUSH | ACTIVATE_SONAR);
}
else
{
c_move(me,vector(30*time_step,0,0),nullvector,IGNORE_PASSABLE | GLIDE | IGNORE_FLAG2 | ACTIVATE_PUSH);
}

if(time_passed<=0)
{
use_sonar = OFF;
}

if(trace_hit)
{
//my.event = bounce_off;
bounce_off();
}

if(my.x < ent_catcher.x )
{

wait(1);
reset(my, SHOW);
ballsInField-=1;
break;
}


wait (1);

}
© 2023 lite-C Forums