Dev Blog - Movement in RuneScape

Praat hier over nieuwe of toekomstige updates. Alle onderwerpen over updates die minder dan een maand in het spel zijn plaats je hier. Discussies over andere games van Jagex mogen hier ook.
Forumregels
Praat in dit forumdeel mee over recent nieuws of toekomstige updates. Mocht je een zodanig klein nieuwtje hebben dat deze echt niet in een apart discussietopic past, dan kun je in de Wacht Lounge terecht. Het is normaal gesproken echter de bedoeling dat er voor elke toekomstige update een apart discussietopic aangemaakt wordt, waarin tot de datum van release over deze update gesproken kan worden. Zodra de update er is, wordt de discussie door een moderator gesloten en kan er in het nieuw aangemaakte topic van Bot verder gediscussieerd worden.
Bot
Forumbot
Berichten: 1010
Lid geworden op: woensdag 5 december 2007, 17:55

Dev Blog - Movement in RuneScape

Bericht door Bot »

Dev Blog - Movement in RuneScape

Originele tekst

Hello! I'm Mod Nin. If you tuned into the Runescape keynote at Runefest in October, you would have seen a few technical prototypes of various game features. For one of them, called 'Smoother Movement', we showed a video of a character running through the Tree Gnome Village maze, turning around corners as smooth as butter. That feature is almost ready for you all to play with! And, if you're curious, I'd like to explain a bit about how we've made this seemingly simple change.

Your browser does not support the video tag.

To understand, we first need to go over how movement in Runescape works. This means knowing a little bit about how Runescape functions in general.

When you play Runescape, you interact with the game client - that's the program you've downloaded to your device. This client connects to a game server, which is run by us at Jagex. The distinction between these is:
  • The game server processes almost all of the game logic (e.g. character movement, combat scripts, skilling scripts)
  • The game client displays the world as it is on the server. It cannot directly move your character, but can tell the server to move your character.
The important point here is that the movement of any player or NPC character in Runescape is controlled by the game server. Every 600 milliseconds (a game tick) the server updates your character's position and sends it to your game client. This is aligned to a grid.

But if that is all you saw, then your character would be moving very strangely...

Your browser does not support the video tag.

To make this look more natural, the client interpolates between the character's last position and their new one, and makes them do a nice animation. Whenever the client receives a new position, we add it to that character's 'pending route', and animate them through it at a fixed speed, depending on whether they are walking, running, or crawling. If your character ends up too far behind its new position, its speed is increased by a fixed amount until it's caught up.

Your browser does not support the video tag.

Step it up!

This is how movement has been in Runescape since at least the launch of Runescape 2 back in 2004. It's done a fine job of representing how player and NPC characters move, but there's definitely room for improvement. We're not aiming for a huge fundamental change to the movement here (sorry, the grid-based movement has to stay for now!) but here's the two big areas we can improve upon:
  • 1. Characters start and stop instantly with no acceleration or deceleration, and change speed suddenly during movement. This is particularly nauseating if you use Classic camera mode.
  • 2. When turning, characters start moving in their new direction immediately. This makes turning look jagged and unnatural.
Fluidity/acceleration/deceleration

Rather than moving the character at a fixed speed, we will now give them an acceleration in addition to speed. When they start moving, we transition their speed from 0 to full-speed over the course of around 200 milliseconds. Then, when the server tells us that there's no more movement, we can decelerate back to 0. This will also apply when changing speed during movement. If your character runs out of energy and starts walking, they will slow down a bit more gently.

We've also been able to add a smarter 'catch-up' system. As I said earlier, your character would suddenly speed up if they ended up too far behind their actual position. With our new method of handling speed, we can make this a bit more seamless by subtly adjusting the character's speed based on how far behind they are. The longer the route, the faster the character moves - and when their speed changes, it does so gently. As well as making catch-up more seamless, this very slightly improves how responsive your movement inputs are; the closer we keep your character to the end of their pending route, the faster you will see them reach their most recent position. This will be happening all the time and, if I've done my job right, you should never even notice!

Turning

Turning is where things get interesting! It would be really nice if, instead of following our route in straight lines, we could follow it using curves as well. A simple and effective curve we can use is a Bzier curve (pronounced "beh-zee-ay"). Without getting into too much detail, a Bzier curve is a parametric curve created by interpolating between a number of points. In our case we will have three points per curve, so our curve will be a quadratic Bzier curve.
Afbeelding
However, it's not enough to just take our existing points and turn them into curves. We'd end up with a bit of a mess, where our curves wouldn't line up properly depending on where we began our movement, and some turns would be more tight than others. Your character might also end up cutting corners and phasing through walls, so we need to do a bit more to make this work.
Afbeelding
To tidy this up we just need to add more points along the way. Whenever we receive a new position from the server, we need to create additional points at half-tile steps towards that new position. Then, we only generate curves from every other point to make sure that we always enter and exit a tile in a way that will align nicely with the next point.
Afbeelding
Great! Now we have some nice curves to interpolate across. When we move our character, we can take our speed and use it to move along our curve, with smooth acceleration and turning! In practice it's a bit more complicated (what happens if we receive our next position a bit late and have to start a new curve from the middle of our last one? Or if we only have two points?) but that explains the general inner workings of this new movement.

Your browser does not support the video tag.

That wraps up this post. I hope you enjoyed reading it. Before I joined Jagex in 2016 I really enjoyed reading through the NXT dev blogs, so I hope some of you found this interesting! I'm part of the new 'Core Experience' team on Runescape, a team dedicated to making the general game experience better wherever we can, so expect more improvements like this in the future!

Mod Nin, Game Engine Programmer
Plaats reactie