Xonotic Forums
Getting Position of Other Players/Bots Client-Side - Printable Version

+- Xonotic Forums (https://forums.xonotic.org)
+-- Forum: Creating & Contributing (https://forums.xonotic.org/forumdisplay.php?fid=10)
+--- Forum: Xonotic - Development (https://forums.xonotic.org/forumdisplay.php?fid=12)
+--- Thread: Getting Position of Other Players/Bots Client-Side (/showthread.php?tid=5465)



Getting Position of Other Players/Bots Client-Side - ehrenbrav - 05-04-2015

So I'm adding support for haptic feedback in Xonotic using a wearable device I'm developing. I successfully did this previously for AssaultCube, but I've been having trouble with Xonotic since I'm not familiar with the darkplaces engine.

To get started, I simply need to be able to get the positions of the other players/bots in the game from the client-side...I imagine this should be pretty straightforward but I've been having trouble figuring out how to do it. Is there an elegant solution out there?


RE: Getting Position of Other Players/Bots Client-Side - Halogene - 05-05-2015

Im curious how the haptic feedback would work? Will you get electro shocks from the right side when getting hit by the vortex or so?


RE: Getting Position of Other Players/Bots Client-Side - Mario - 05-05-2015

I'm not sure if the engine can know the player locations as easily as the game code, as that's where we handle them mostly.
If the majority of your functions are done in the engine, a game code hook could be added which allows telling the engine where players are and everything (although, I'm not sure if this is the best way).
I suppose one example of a game code hook that handles player related stuff is runstandardplayerphysics.


RE: Getting Position of Other Players/Bots Client-Side - ehrenbrav - 05-05-2015

(05-05-2015, 01:24 AM)Halogene Wrote: Im curious how the haptic feedback would work? Will you get electro shocks from the right side when getting hit by the vortex or so?

The initial mode I'm implementing is basically tactile radar - you *feel* where the other players are in the game. I encode range and bearing (and can do friend/foe) in the pulse frequency and intensity of the haptic feedback. This works pretty well for AssaultCube, but I'd love to implement it for Xonotic. The haptic actuators in this case are little vibrating motors a la the ones you have in your mobile phone.

(05-05-2015, 06:15 AM)Mario Wrote: I'm not sure if the engine can know the player locations as easily as the game code, as that's where we handle them mostly.
If the majority of your functions are done in the engine, a game code hook could be added which allows telling the engine where players are and everything (although, I'm not sure if this is the best way).
I suppose one example of a game code hook that handles player related stuff is runstandardplayerphysics.

Yeah, that's precisely the impression I got. It would be comparatively easy to implement server-side I think.

My thinking was pretty simple - as only a few players will actually have the haptic feedback peripheral, I didn't want to burden the server with having to manage it and would prefer to just keep this all client-side. It seems like a game code hook might be a good solution (or at least *a* solution) - I guess I would implement as follows:
1. If the client detects the player has the haptic feedback device, it asks the server to send the player positions every couple of frames.
2. The server does so when requested.
3. The client then calculates the relevant ranges and bearings, and then communicates this to the haptic driver.

That was a bit more involved than I was hoping, but I suppose should work unless someone can think of another way that doesn't involve the server at all...

Thanks for your suggestions,
E


RE: Getting Position of Other Players/Bots Client-Side - Mario - 05-05-2015

I should note that the client doesn't know where every single player is (especially ones behind walls). It only networks entities in the same room/area, to save bandwidth and prevent cheats.
Player locations are already networked when visible, identifying them from the client may be a bit difficult though (maybe searching every entity number below the maxclients variable could be easiest, as these are always players).


RE: Getting Position of Other Players/Bots Client-Side - ehrenbrav - 05-06-2015

(05-05-2015, 11:50 AM)Mario Wrote: I should note that the client doesn't know where every single player is (especially ones behind walls). It only networks entities in the same room/area, to save bandwidth and prevent cheats.
Player locations are already networked when visible, identifying them from the client may be a bit difficult though (maybe searching every entity number below the maxclients variable could be easiest, as these are always players).

You know - a good starting point would be to look at how the map is implemented in team deathmatch. In that case, you can see the locations of your teammates on the map in the upper left corner of the screen, so couldn't you essentially just tweak this feature to accomplish what I was going for?


RE: Getting Position of Other Players/Bots Client-Side - Mario - 05-06-2015

That uses a special entity linked with CSQC. If all you really need is the player's rough locations, it may be enough.


RE: Getting Position of Other Players/Bots Client-Side - ehrenbrav - 05-10-2015

(05-06-2015, 12:14 PM)Mario Wrote: That uses a special entity linked with CSQC. If all you really need is the player's rough locations, it may be enough.

Well - works like a charm! I now have haptic radar to detect my teammates in CTF. It works by reading the radar updates sent by the server and re-purposing by converting the spacial location into haptic feedback.

I'm wondering what to implement next...maybe haptic detection of power-ups, flag-carriers, and waypoints? Anything you see on the team radar I should be able to grab solely on the client side... The beauty of this from the player's perspective is that you don't need to look at the team radar while playing Wink

Thanks again for your suggestions,
E