Jump to content
Sign in to follow this  
jhonenglish

Problem with a While loop

Recommended Posts

Hello there and thank you for giving attention to to my problem. 

Im creating an intro in which a camera follows a player (see below), but for some reason it wont exit the while loop, anybody got an idea why?

 

StopFollowing = 0;

Follow = 0;

 

T1 = createTrigger ["EmptyDetector", [0,0,0] , false];
T1 setTriggerStatements ["StopFollowing = 1","Follow = 1",""];
T1 setTriggerTimeout [5, 5, 5, false];                                                                                           // i set this trigger with a timeout so it will turn the While condition false after 5 sec

StopFollowing = 1;


titleCut ["", "BLACK OUT", 2];
sleep 1;
titleCut ["", "BLACK IN", 3];


while {Follow isEqualTo 0} do {
_camera camPrepareTarget man1;
_camera camPrepareRelPos [1,1,3];                    
_camera camPrepareFOV 0.700;                                    
_camera camCommitPrepared 0;                                    
WaitUntil {camCommitted _camera};

};

Share this post


Link to post
Share on other sites

Maybe start with the trigger: https://community.bistudio.com/wiki/setTriggerStatements. But your StopFollowing variable has no purpose in the above script. StopFollowing is immediately declared as 1 straight after the trigger is created. But the trigger statement is written wrong (== not =). But the script is a bit confusing, so I'm not sure if that's actually meant to be your condition. You could just cut the trigger away altogether and use a distance2D check in the loop:

while {(_unit distance2D _position) > 10} do {
	//code
};

Where _unit is the unit that the camera is following, and _position is where it's going to. So you could adjust that condition to end at a different time. Depends on what you're actually trying to do though.

Share this post


Link to post
Share on other sites
21 hours ago, beno_83au said:

Maybe start with the trigger: https://community.bistudio.com/wiki/setTriggerStatements. But your StopFollowing variable has no purpose in the above script. StopFollowing is immediately declared as 1 straight after the trigger is created. But the trigger statement is written wrong (== not =). But the script is a bit confusing, so I'm not sure if that's actually meant to be your condition. You could just cut the trigger away altogether and use a distance2D check in the loop:


while {(_unit distance2D _position) > 10} do {
	//code
};

Where _unit is the unit that the camera is following, and _position is where it's going to. So you could adjust that condition to end at a different time. Depends on what you're actually trying to do though.

 

Thanks. solved the problem... distance condition is not what i need, i needed the camera to follow somthing to a certain amount of time.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×