Think of a situation with two distinct runners with different speeds. They will have to walk a circuit in a straight line with two obstacles (police).
Below is an illustration of the situation:
The problem I'm having is the following:
Assuming that runner two is faster than runner one, it is certain that he will reach the first hurdle earlier. Upon reaching this obstacle (detection event) he will be stopped for five seconds, long enough for the runner to reach him.
However the runner one will go through this obstacle without any loss of time, since the policeman is already taking care of the runner two.
Runner one still manages to get to the second obstacle with runner two still standing ... Then the problem arises because as they are equal objects the game assumes that the policeman is already taking care of the runner two, so the runner one passes straight through.
I would like to know how to do each object independently (detection event).
Sorry for the translation errors! Thanks!!!
Codes:
Movement (obj_control) =>
move_towards_point(obj_runner_01.x,obj_runner_01.y-1,obj_runner_01.manSpeed);
move_towards_point(obj_runner_02.x,obj_runner_02.y-1,obj_runner_02.manSpeed);
Collision detection (detector) =>
event_colision...
if obj_detector.detector_runner_01==false{
randomize(); //in the original case, there is a chance the runner will not be stopped
numRandom=irandom(99)+1;
obj_detector.detector=true;
}
if manColision==false{
if numRandom<=manAtrat*0{ //test value
manColision=true;
}else{
time_runner_01+=1;
if time_runner_01<150{
if obj_detector.stopped==false{ //variable that indicates that there is a stopped runner
move_towards_point(x,y,0);
}else{
time=150;
}
}else{
if pos==1{
move_towards_point(x,y+1,manSpeed);
}
if pos==2{
move_towards_point(x-1,y,manSpeed);
}
if pos==3{
move_towards_point(x,y-1,manSpeed);
}
if pos==4{
move_towards_point(x+1,y,manSpeed);
}
obj_detector.stopped=true;
manColision=true;
}
}
}
OBS- THE ORIGINAL CODE DOES NOT AND SO, CONTAIN OTHER THINGS, I EDITED THE NAMES OF THE VARIABLES TO MAKE SIMPLES THE UNDERSTANDING
To see if it is possible to have independent variables between equal objects I did a test =>
obj_detector (box with star) create event =>
test=irandom(10);
obj_detector (draw event) =>
draw_self();
draw_text(x-10,y,test);
Three different values for the same variable in the same object!!!