30.09.2010, 17:54
Im making a script of a moving ship. To make the movement more realistic im trying to accelerate the ship when it starts moving. Im using this code:
top:
filterscriptinit:
commandtext:
The ship does accelerate, BUT, it does it lagging. The objects of the ship (only 6 atm) rapidly move forward/backward and it's very annoying, then when the ship get to max speed it's all right. But the accelerating process is laggy.
So I tought "maybe a 500 ms timer is too fast", so I put 5 SECONDS timer, the problem doesn't go away. I tryed to change the + 0.2 value to a micro value and to a big value, objects still lag.
So I tough "maybe the for is making this lag", so I removed the for and tryied with only one object. It was still lagging. I tryied to put 5 seconds timer, change the + 0.2 value and using it with only 1 object. Still lagging. The objects rapidly move forward and backward and it's horrible to see.
Objects lag also when the ship decelerates, I won't post the code as it's almost exactly the same as the accelerating one.
This is a filterscript, objects are 6, I am not using a streamer, and maxspeed value is 3.0
How to solve this lagging issue? Thanks.
Код:
public MoveShip(Float:speed) { for (new obj = 0; obj < shiptot; obj ++) { new Float:x, Float:y, Float:z; GetObjectPos(obj, x, y, z); MoveObject(obj, x - 1000, y, z, speed); } if (speed >= maxspeed) return 1; SetTimerEx("MoveShip", 500, 0, "f", speed + 0.2); return 1; }
Код:
new shiptot = 0;
Код:
for (new obj = 0; obj < 100; obj++) { if (IsValidObject(obj)) shiptot ++; }
Код:
if (!strcmp(cmdtext, "/move", true)) { MoveShip(0.0); return 1; }
So I tought "maybe a 500 ms timer is too fast", so I put 5 SECONDS timer, the problem doesn't go away. I tryed to change the + 0.2 value to a micro value and to a big value, objects still lag.
So I tough "maybe the for is making this lag", so I removed the for and tryied with only one object. It was still lagging. I tryied to put 5 seconds timer, change the + 0.2 value and using it with only 1 object. Still lagging. The objects rapidly move forward and backward and it's horrible to see.
Objects lag also when the ship decelerates, I won't post the code as it's almost exactly the same as the accelerating one.
This is a filterscript, objects are 6, I am not using a streamer, and maxspeed value is 3.0
How to solve this lagging issue? Thanks.