Log 22: Oh Good, a More Immediate Problem
- Kassandra McCormack
- Oct 31, 2024
- 3 min read
No surprise, once I tried getting the Group attack to work I realized I had several potential problems that I would have to either solve or work around.
What if the player starts the attack while standing next to a wall? I can't teleport the characters into it.
There's a similar problem with the player starting the attack on a slope, either teleporting their allies into the slope or into the air.
Speaking of teleporting allies into the air, what if the player is standing next to a cliff, or on the edge of a building?
I figured all these could be solved with clever uses of line traces and moving the player. But one problem would not be solved easily: hordes of enemies. The central conceit and driving mechanic for Warriors games is that the player will, more often than not, be neck deep in large groups of enemies. What do I do when the player is in this situation and activates the group attack? Just letting them stay there would look awful, so how do I move them out of the way? This was the hardest because I had no clue how to do this when I started.
The first thing I did was put a handful of dummy basic characters into the level to see how just teleporting the allied characters into a group would work. The upside is they teleport in even if there are enemies in the space, the bad news is that I discovered if the player tries to move through a group of enemies they will sometimes bounce off. Sometimes to the point of flying out of the level. This is the exact opposite intended outcome and something I needed to fix right away.
There is a way to disable the Character Move Component and use physics to move characters, as easy as a toggle somewhere because I tested it before. But I couldn't find it so I had to look elsewhere for a solution. Many forums online suggested using the "Add Impulse" node, which worked okay. This is what I had been using when I started working on the Group attack, but then I discovered that if the player character brushed by an enemy or attempted to move through a group of them the player character would get flung away. Which is the exact opposite of what needs to happen.

Eventually after more research I found a post that made me feel like an idiot. Instead of adding impulses, just use the Add Movement Input node that gets used in the regular movement code. This led to the enemies barely moving.

Not only would they barely move as a result of single frame movement input, but they would be unable to push other enemies out of the way in a group. So I made a new component that applies constant movement input through an interface. This led to...interesting effects:

After I fixed that up (I mixed up the functions for Begin Overlap and End Overlap...somehow), it mostly worked but the player character would still occasionally bounce off the enemies. Eventually I discovered that if I widened the base collision capsule a little bit, and changed some of the collision properties on the skeletal meshes, the bouncing stopped. My estimate is that some weird collision interactions were going on where colliders were forcing themselves apart because they weren't supposed to be able to overlap like I was forcing them to.
I would eventually go back to Add Impulse over Add Movement Input for the simple reason that I didn't like the enemies changing direction as they were pushed, I wanted them to keep their rotation. Fortunately now that the characters were applying impulses to themselves there was no way for it to backfire on the player character, if that was even what was going on in the first place.

There's still some unfortunate stuttering on the enemies when pushed, but that has more to do with their animation blueprints just looking at velocity period and not at all why the velocity is changed. Fortunately that is low enough priority that I can put it on my ever-growing to do list and address it later. I could address it now, but I need to learn how AI movement works in Unreal before I go committing to anything.
Hopefully next update I'll be able to report continued direct progress on the Group Attack.
Comments