Spriterfight 10 Posted January 23 I have a while loop and i created a function that updates a certain position, the problem is it dosent execute everytime it is called in the while loop only once, so the object that i want to move only moves towards the first position thaht the function has created Share this post Link to post Share on other sites
Harzach 2517 Posted January 23 9 hours ago, Spriterfight said: I have a while loop and i created a function We can't see them from here. Show your code! Share this post Link to post Share on other sites
Spriterfight 10 Posted January 23 I put the function in the init.sqf is it bad practice? Share this post Link to post Share on other sites
Harzach 2517 Posted January 23 Not necessarily. But as we can't see your code, there's not much more to say. Share this post Link to post Share on other sites
Spriterfight 10 Posted January 23 func_PredictIntrecept = { _target = _this select 0; _aircraft = _this select 1; _targetPos = getPos _target; // Get the velocity of the target _targetVel = velocity _target; // Get the current position of the aircraft _aircraftPos = getPos _aircraft; // Calculate the time it will take to reach the target _timeToTarget = (_aircraftPos distance _targetPos) / (speed _aircraft / 3.6); // Calculate the future position of the target _futureTargetPos = _targetPos vectorAdd (_targetVel vectorMultiply _timeToTarget); // Calculate the direction to the future target position _directionToFutureTarget = _aircraftPos vectorFromTo _futureTargetPos; // Calculate the interception point _intersectionPoint = _futureTargetPos vectorAdd (_directionToFutureTarget vectorMultiply _timeToTarget); // Create a marker at the interception point (for debugging purposes) _markerStr = createMarker ["markername", _intersectionPoint]; _markerStr setMarkerShape "RECTANGLE"; _markerStr setMarkerSize [100, 100]; // Display a hint for debugging hint "OK"; _intersectionPoint; }; This is my code which predicts intrecept position of a target, i fixed it by simplifying the formula(it has an object attached to it and wanted a relase position where the plane relases it to hit target, nevermind it is complicated and arma has strange physics).The problem was it seemed to be a delay and the plane moved behind the target.It needs to be updated every second.It seems to be work, but i want to be sure that it executes instantly and there are no delay since accurate position is crucial Share this post Link to post Share on other sites
Harzach 2517 Posted January 25 I set up a target aircraft in a loiter pattern. A second aircraft is the interceptor. I am running your function in a loop 10 times per second. Your function is executing very quickly, so that's no issue. As far as making one aircraft intercept another, it seems to work great, the interceptor chased the target around the loiter circle, catching up, then breaking off and re-engaging. But perhaps you are defining "intercept" differently. What exactly is it you are trying to accomplish? Just out of curiosity, I also tried having two aircraft intercept each other, It produced an epic round of flat scissors: Share this post Link to post Share on other sites