Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (744)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (825)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [Kryonet] Runescape style movement  (Read 2275 times)
0 Members and 1 Guest are viewing this topic.
Offline Emmsii
« Posted 2017-10-08 17:05:54 »

I've been wondering how to implement a movement system similar to that in Runescape. Basically the world is a grid, a player can click on a grid tile to find a path towards it. Up, down, left, right and diagonal movement would be allowed.

I've thought of a few options.

1. Player client clicks on tile > sends move request to server > server does checks (can walk on tile, distance to tile is short enough, etc) > send move player packet to clients (packet contains destination tile and player id for example) > client receives packet > client finds path towards tile and moves towards it.
2. Player client clicks on tile > sends move request to server > server finds path to destination > sends list of points that make up the path to clients > clients use path data to move player.
3. Player client clicks on tile > sends move request to server > server finds path to destination > player moves on server > server sends packet to client every time the player changes tile (or every x times a second) > client receives packet and moves player by 1 tile.

Number 1 seems like a bad idea, letting the clients find the path towards a location. Number 2 seems better but sending path data to clients seems a bit expensive. Number 3 seems good but might be tricky to implement and might not feel that stable.
Offline Archive
« Reply #1 - Posted 2017-10-08 17:38:44 »

As far as I remember, the runescape client had the pathfinding code in the client but the "collision" was handled on the server side. So #1 is actually the most true to the original game.

Offline Emmsii
« Reply #2 - Posted 2017-10-10 07:54:13 »

So the client would find the path, ask the server can I walk this path, the server checks if the path collides and tells the client yes or no.

Would that involve the server also finding the path to check if its valid, or would the client send the path to the server to check, so the server never does any pathfinding.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline KevinWorkman

« JGO Plugged Duke »


Medals: 272
Projects: 12
Exp: 12 years


HappyCoding.io - Coding Tutorials!


« Reply #3 - Posted 2017-10-11 02:21:26 »

Would that involve the server also finding the path to check if its valid, or would the client send the path to the server to check, so the server never does any pathfinding.

Why would the server need the path? The client is just asking whether it can go from square A to square B. It doesn't need to care about square C or D or E...

If you're really worried about users hacking the client to make arbitrary moves, then neither option 1 or 2 will prevent that. But 99% of the time, these kinds of concerns are premature.

HappyCoding.io - Coding Tutorials!
Happy Coding forum - Come say hello!
Offline Emmsii
« Reply #4 - Posted 2017-10-11 07:04:15 »

Yeah good point, I was thinking a better method might be to let clients do the pathfinding and have the server validate each move to a new tile before sending the move order to other clients.
Pages: [1]
  ignore  |  Print  
 
 

 
Ecumene (150 views)
2017-09-30 02:57:34

theagentd (222 views)
2017-09-26 18:23:31

cybrmynd (301 views)
2017-08-02 12:28:51

cybrmynd (289 views)
2017-08-02 12:19:43

cybrmynd (298 views)
2017-08-02 12:18:09

Sralse (291 views)
2017-07-25 17:13:48

Archive (978 views)
2017-04-27 17:45:51

buddyBro (1102 views)
2017-04-05 03:38:00

CopyableCougar4 (1678 views)
2017-03-24 15:39:42

theagentd (1430 views)
2017-03-24 15:32:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!