I planed to do player charging from very early on, but I guess it takes 100 posts for me to actually get to it. This is the kind of feature that should be added at the earliest opportunity for it can be tested. Then again, my predominant process seems to be mentally imagining features working before ever making them work. I guess it’s a two-sided coin — if I get it wrong, I am creating an unfun game; but if I get it right, I can approach implementation efficiently without shoehorning features before they are ready for the architecture.
Anyway, charge. I will likely call it “boost” ingame for lore purposes (being part of robot’s equipment), but call it “charge” here. So the charge is basically a triggered speedy directional movement — a power sprint.
First thing’s first, a new asset (this is my motto now for every feature; my custom asset menu is so long I need to scroll through it):
I guess the primary value I care about is the duration of the charge:
Before I can use the charge, I need a control for it (which is a bit of a process with the plugin):
Then I can wire it in-game. I do want to add logic first before I add any gameplay, so I need a debugger to see what is happening:
And it works! Well, logically anyway.
The actual value will come from the player’s charge/booster gear, so I want to store the appropriate value there:
Unchanged would be the default amount for a starter or white item. Then I can specify the better values with their per-level bonuses:
This feels a little cheap — my more advanced leveled items are just more powerful. But I guess that’s kind of like getting a lower tier item 5 levels early. I’ll think on it more, though I don’t know what non-scope-creepish change I could make.
And wiring the numbers in, I get the improved leveled values (as seen in debug output):
Another value that’s pretty core to the charge is the speed (increase):
Similarly, I specify that for gear:
And, similarly, I scale that by levels and quality:
And I can show the resulting speed as well (in debug):
So now that it all works logically, I should wire it in the actual game. And after some fiddling around, it works out:
Besides logical values, in the actual gameplay I need to consider the direction in which the charge happens. This is actually a tricky question. I think I will use the movement direction. That is, wherever the player is moving (so pressing WASD or leaning stick) is the direction the charge will initially move towards. The consideration is if the player isn’t moving. So I will use the aim direction then — wherever they are aiming. (I might consider making this an option, although I doubt it’s useful to charge like that because one would have to really work the mouse/stick.)
One tricky part I discovered that I cannot use player’s actual movement direction, I have to use the latest input. The player might run left, then press right and charge before the avatar has even turned around. This would send the player charging in the “wrong” direction.
In any case, that works and the player charges in the right direction.
<do not forget to put a well-edited GIF here>
Another thing is to consider charging direction while charging. Currently, it selects a direction and then just goes in a straight line. I don’t want to actually restrict the direction or make it too difficult to change direction. I want to keep it fun by letting the player turn if they want to. I just want to add a small penalty that doesn’t make charging perfect. Or, rather, requires some effort and mastery to actually use in combat. I want a little bit of inertia to it to convey the “heavier” directional nature of charge versus walking. And I rather have an ability that lets you use it fairly freely and make sure the rest of the game is balanced with it in mind. Rather than restrict the ability so that it doesn’t mess up the balance of the rest of the game.
So I am adding a control variable that describes how difficult it is to turn:
Although I quickly realized that it makes no sense, since movement changes are essentially instant. I need a more abstract “angle change per time” value:
And this works really nicely — the player can change their charge direction very quickly:
It still takes some precise input or they will run into a wall. But that’s a sort of reward-based skill… sort of. I mean, it’s fun to use and solves some of the movement concerns, so that’s already enough for me.
This already took quite a while to do — plan, design, implement. And this about implements the player’s side of charging. I still have a lot of things to add and tweak, so I will cover that in a separate post.