Hi everyone !
Lucas here, back at the devblog writing desk ! Today, we are going to get technical with one of my latest task: improving player controls and targeting system.
Controls have been an issue of Wolcen for quite some time now with players experiencing difficulties to target enemies, complaining about the clunkiness and having the feeling the controls weren’t responsive enough.
These issues are imputable to two subsystems of the controls of our game:
- The targeting system which is responsible for detecting what is under your mouse cursor
- The player input system which is responsible for handling all the logic when you press a key on your mouse or keyboard
Let’s talk about targeting. We started improving this a few months back with 0.4.0. First, let’s lay some basics. In order to know what is under a player mouse cursor, we use raycasts.
Raycasts are special rays that go from point A to point B in straight line and give the programmer back information about every object it hit on its way from A to B.
Using this, we can raycast from the mouse cursor position to the ground in order to get what you are aiming at, simple right ? … well, not so much.
This indeed works when the target is under your mouse cursor. However, given that enemies are moving and are animated, this solution alone makes enemies hard to target because you must have some part of your target body exactly under your mouse cursor where we perform the raycast for the target not to be lost.
Our solution to this issue has been to create a special invisible capsule, much bigger than the enemy, that can be picked up when doing a raycast. This way, you are considered to be targeting an enemy if your mouse is around the enemy, no longer only when your mouse is exactly on top of the enemy.
This is what happens when programmers draw schematics…
In game debug view of our custom capsule
As you can see, now, if your mouse hover the yellowish area around an enemy, the game will consider you are targeting this enemy making targeting much more easier even on moving targets. However, this wasn’t enough for our fastest enemies like the ghoul or in some situations. This is where the player input system comes into play.
What’s happening when you press a key/mouse button ?
Before 0.5.0.1, when you pressed a skill key, the game checked if you had the right to cast this skill (Are you alive ? Do you have the rage/umbra required ? Is the skill in cooldown ? etc…) and if so, simply casted it.
This approach, while straightforward and very simple, has one major issue :
If you are spamming your left mouse button to attack an enemy and cast a skill in the middle, there is a very high chance your skill won’t cast because you weren’t in a state where you can cast a skill at the time you pressed the skill key, resulting in your input being lost and not producing any feedback.
The solution to this issue is called input buffering and works as follow:
- When you press a key, the associated action is added to a queue
- When your player is in a state that allows actions to be executed, the input system execute the first action in the queue
In Wolcen, our queue only contains 2 items: the action currently executing and the next action to be executed after the current. If we had an infinite queue, you could spam brutal strike 20 times and take your hands off of your keyboard and watch your character launch 20 brutal strikes successively.
As a result, if your input queue is already full, the last input will override the action at the end of the queue. As it is more recent, we consider you want to do this action over the one that previously was queued.
Moreover, the queue will prioritize some actions over others. Let say you are spamming brutal strike and suddenly decide to cast rain of fire but keep spamming brutal strike after that. In this case, even if brutal strike spammed inputs are newer than your rain of fire input, we keep the rain of fire because it is different from the skill you were spamming and, therefore, we consider this is an important action that must execute.
There is a lot of other smaller rules to manage skills that require you to hold down the skill key like fire breath, whirlwind or lightning strike but I won’t get into it here because it would take pages and pages to describe all the small specific use cases.
Back to our targeting issue then. This input buffering system also allows us to give the player the ability to “lock” a target by clicking and maintaining the left mouse button. Doing this, your character will now move toward the target you clicked on and will automatically attack it as long as you hold down your left mouse button which solve our targeting issue with fast moving targets.
The moral of all of this is the following: controls are really hard to get right. Even for a action RPG where things seems to be quite simple: click somewhere to move, click on something to attack, press a key to cast a spell… there is an underlying complexity even for the most simple things like accurately know what is under your mouse cursor.
Our custom collider solution for targeting has been in use for about three months now and even if there still is some minor issues that need some tweaks, we are happy with the overall result.
On the other hand, our input buffering solution is brand new and, even if it has been used in multiple games from the genre and has proven it’s effectiveness, our implementation in Wolcen will require testing over an extended time frame and will probably be mature only in a few months after many tweaks, but we are confident it will reduce the clunkiness feeling expressed by many players and will give you a greater feeling of control over your character.
We can’t wait to get your feedback on all of this !
Thank you all for your continuous support and all your enthusiastic messages on kickstarter, discord, steam forums and email !
PS: if you want to learn more about controls in Hack & Slash/ARPG you should definitely check this talk from Blizzard which talks about Diablo 3 controls. It has been a huge inspiration for our input buffering implementation and it covers many subjects I talked about in this devblog in great depth. A big shout out to the guys from Blizzard for sharing this awesome piece of knowledge with the world !