Fixing Pawn Jitters


5/18/2023

By Will Fox

Hey All! This week, I worked a lot on sound effects. Since that isn't very interesting, I'm going to talk about a smaller yet more important bug that I ended up working on and fixing. Ever since we created the skeleton AI, it has always had an issue with jittering every time it shot an arrow. This was pretty annoying since it definitely takes away from the immersion of our game and we don't want that. So, here is how I fixed it.


For starters, I checked all of the collision details for the arrow mesh. Since I worked on fixing collision for large meshes and what not for our big boss levels, I am pretty familiar with what to check for in the mesh collision section. It's a little strange, but collision doesn't take place directly on the mesh. Instead, it's the material itself that you need to enable collision for. Pretty weird, right? There's a tiny little check box called something like "Enable Collision." I'm not sure if that's the exact name, but, that pretty much turns on collision for your object. And of course, you also need to select the "Use Simple Collision as Complex" which will use the complex collision mesh that Unreal makes for you. BUT, this ended up not being the issue. When I went into the arrow mesh, the check box for the material collision was already disabled which meant it wasn't causing any collision issues in that area.


The next thing I checked was the specific collision options for the box collision that sat on the arrow. Essentially, the arrow uses box collision to check if it's hitting anything. If it collides with terrain or the player, then it will deal damage and destroy itself. So, when I looked deeper into the box collision, I dug up the problem for the skeleton jitters. Basically, under the "collision" section for the box collision, you can customize the specific world objects and actors that you want your collision box to interact with. One of these options it "actors." Now, there are three options that you can select. Ignore, collide, and block. Ignore will simply ignore the collision (as if nothing happened), overlap will call a collision event on the collision box, and block will both call an event on the box collision and also physically stop/bounce the actor on whatever it hits. The arrows box collision had "block" selected for actors. This is why the skeleton was jittering. The arrow is pretty much spawned on the skeleton, and the "block" part of the arrow is causing there to be some physics between itself and the skeleton. It would have been a lot easier to simply switch "block" to "overlap" since overlap wouldn't cause any physics to happen. However, the "On Component Hit" node has a pin on it that allows us to see exactly where the arrow collided and we need that location in order to leave a "decoration arrow" (basically just an arrow for show so it looks like the arrow is stuck to whatever it hit.)


So, here is the fix. Shrink the collision box. By doing this, it makes it so the arrow won't be in the way of the skeleton. I'm going to look more into this issue because I think this is only a temporary fix and I want to be able to spawn a projectile wherever I want, whenever I want without there being any funky physics happening. 


Leave a comment

Log in with itch.io to leave a comment.