Fixing client lag (delay movement)? (any math wizzes plz help)

Started by
2 comments, last by ApochPiQ 9 years, 2 months ago

ok, heres what I'm doing: I have a model spawned and I have a for loop that will keep setting it to the player's location every .05 seconds (minimun time allowed by the engine)... And it works fine, but if you move too fast or spin too fast, it will be like a second behind the player, causing it to go through the player. The language is called GSC ( Call of Duty's personal language), but it is alot like other scripting languages. Heres my script and I want to know if anyone can think of any ways to do it. My friend has done it and figured it out while he was scripting in Javascript (i think). Then he converted it to GSC. But he wont tell me how he did it so... I would like to figure out it.


for(;;)
{
  model.origin = self.origin + (0,0,50);
  model.angles = self.angles;
  wait(.05);
}

self is the player, and model is my model that will lag into the player when moving fast (aka sprinting). .origin and .angles are already defined via the engine. This is a picture of what the model looks like on a playermodel (this is not the player because I did not have third person available when I built the mod).

hyK9l.jpg

I hope someone could help think of a way to stop it from entering the player

Advertisement
I'm not familiar with the scripting system you're using, but traditionally script engines have a "per frame" callback that is invoked every time the game engine updates. You should look for such a way to run code - every game frame instead of every 0.05 seconds. That is the best way to correct the problem.

[edit] Afterthought: if the engine allows you to simply specify that one model should be attached to another, e.g. through a scenegraph, you should do that instead of trying to script in the behavior.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

yes i thought of that, and it has that function, but that will delay even more than my method. In case u were wondering about the functions of the engine, the functions can be found http://www.zeroy.com/script/ or http://ugx-mods.com/script/

Poking around for a minute and I ran across this: http://ugx-mods.com/script/#core.Entity.attach

Sounds like exactly what you need.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

This topic is closed to new replies.

Advertisement