• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Client-Side Units [Eliminating Lag]

Status
Not open for further replies.
Level 1
Joined
Oct 20, 2007
Messages
4
Hi, first off, I apologize if this is the wrong forum.

Okay, so I'm making a remake of Run Kitty Run, attempting to get rid of all its defects. The only one that I still haven't figured out is lag, and it's the biggest one. The reason for the lag is this - host-side unit logic. The host controls the units that everyone knows about. They all know the position, AI, seeded random number, everything. They don't need to wait for the host to tell them where the unit is.

The process goes like this:
  1. Host calculates unit position and angle
  2. Host sends unit position and angle to clients
  3. Clients receive unit position and angle
  4. Clients display unit position, angle, and animation
  5. Repeat

The problem is that clients have to wait between around 30 to 200 ms (or more!) to know where the wolf will be next (in order to dodge it). The ideal process would be this:

Startup:
  1. Host distributes random seed
  2. Client calculates wolf positions, movement speed, and angle

Update:
  1. Client calculates new unit position, movement, angle, etc.
  2. Client displays unit

Now the client doesn't have to wait at all! I've looked into this, and I've experimented with a few things, and no such luck yet. I'm asking the experts of hive workshop to see if this really is possible.

Things I've tried (or contemplated) - using Special Effects. I can create a unit model, but how about doing running animations and stuff? Also, the model is sunk into the ground, can it be pushed up? Is it efficient? And most importantly, is it CLIENT SIDE?
 
Special Effects cannot present anything more than the birth, stand and death animations. They are not very dynamic and are stuck in the position you created them (can't set their coordinates nor attachment point).

To get the proper animation would either involve editing the model file to change its default animation, or simply creating a unit. But if it's synchronization you want to achieve, the unit will have to be visible for all players. You can add Locust to the unit to make it unselectable, and then from a GetLocalPlayer() block you can set that unit's scaling value to 0.0 except for the person you want to be able to see it. That's probably the best solution.
 
Level 1
Joined
Oct 20, 2007
Messages
4
Special Effects cannot present anything more than the birth, stand and death animations. They are not very dynamic and are stuck in the position you created them (can't set their coordinates nor attachment point).

To get the proper animation would either involve editing the model file to change its default animation, or simply creating a unit. But if it's synchronization you want to achieve, the unit will have to be visible for all players. You can add Locust to the unit to make it unselectable, and then from a GetLocalPlayer() block you can set that unit's scaling value to 0.0 except for the person you want to be able to see it. That's probably the best solution.

Okay, I've looked at GetLocalPlayer(), but I'm new to JASS (only ever done GUI). I'm wondering how you propose I'd use GetLocalPlayer() to control and update units locally.

What I'm thinking maybe you have in mind is show the unit updates instantly and then if it doesn't sync up with host then move it there? That is probably the best solution, because if it didn't sync up (different computers/amount of updates, and stuff) then there would be some serious side effects or desyncs.
 
Level 1
Joined
Oct 20, 2007
Messages
4
Just to be clear, I don't need the actual players' heros to be 'faked'. That doesn't matter at all. What I do need is for the wolves to be faked. I'm not sure how centering the camera would help putting fake units on each client.

From my programming experience, I am looking for sort of a 'main loop' to hook into. Each time the client calls update_game() I want to update the client's units. The rest of the players do the same, calculate the units' positions, speed, angle, etc themselves. Is there some loop I can hook into (that will be run on the CLIENT'S machine?)
 
so how do you want to control your hero?
movement orders have delay and I don't know if that delay vanishes if you create the units locally
camera movement does not have this delay so you could move the heroes to the position of the center of current camera

and everything is running on the client's machine btw
the game just syncs movement orders, selections and such (imho)

if you want to sync stuff from a specific player at a specific time you can ask nestharus (or use search)

also you can sync stuff over selection (but that only provides a boolean per sync which is a pretty bad rate and also it fucks up selection)
 
Status
Not open for further replies.
Top