Knights’ Knowledge

In this blog I’ve written about the teleportation mechanic and it’s dynamics. Last week I introduced the knight, which is an enemy that blocks the player’s shots from the front with a shield and needs to be teleported behind of to strike the vulnerable back.

screenshot-33

The behavior of the knight is similar to other enemies’ and thus didn’t require much work. Only a few variables were tweaked in the inspector to suit the knight’s attributes, slow and sturdy.

An obstacle was met in an unexpected manner. The collider for the shield with the purpose of blocking shots was also dealing damage to the knight.

What seemed to be the issue was the shield being a child object of the knight. As a standalone object the same effect was not present. That’s clearly not ideal because the shield would have to be manually moved along with the knight and there’s no logic to it in the hierarchy.

Another speculation was made. As a child object, it inherits it’s parent’s tag and thus contributes to the same effects. After trying tagging it differently and adjusting code to include conditions for the tag, the issue persisted.

The prolonged process was then finally concluded. The shield’s collider was connected to the parent knight’s rigidbody. After adding a separate rigidbody to the shield, it became impenetrable as intended. I’m not an expert on Unity, or programming. How I came to the realization was because the problem was gone when I removed the rigidbody on the knight. I could not find any documentation to support this claim, only a single answer to a question posted on Unity’s website.

After the shield was successfully implemented. I proceeded to work on the attack, the sword swing.

screenshot-35screenshot-36screenshot-29

In the beginning we were using a polygon collider, shaped to the swings animation, to act as the hitbox. A group member suggested that they could make a collider inside the animation that would follow the sword precisely. We then implemented that instead, as it would avoid causing the player unexpected damage.

With everything implemented, we tested the knight.

We noticed players couldn’t instantly recognize knights weren’t being damaged when hitting their shields. To remedy that, we added some spark and flame particle effects to portray the fireballs being deflected.

About Lukas Fletcher

2016 Programming