Enhance Your Gameplay with New Weapons and Advanced AI
Table of Contents:
- Introduction
- Adding More Weapons
- Implementing a Weapon Wheel
- Implementing a Dash Ability
- Introducing Enemies
- Creating a Robot Model
- Implementing AI for the Enemies
- Adding Animations for the Enemies
- Setting up Damage Logic for the Enemies
- Conclusion
Adding More Weapons
In this episode, we focused on expanding the variety of weapons available in the Game. Starting with a temporary sword model created in Blender, we added animations and materials to enhance its appearance. However, we soon realized that the sword lacked functionality and required adjustments. We attempted to implement a hotkey and scroll wheel system to switch between weapons, but encountered issues with overlapping animations. After careful consideration, we decided to develop a weapon wheel instead, similar to those used in popular games like GTA and Fallout. This not only allowed for easier weapon selection but also added a cooldown feature to control the speed at which weapons could be switched. We also included an icon in the corner of the screen to indicate the currently equipped weapon.
Implementing a Weapon Wheel
To provide players with more seamless weapon selection, we decided to implement a weapon wheel. This interactive pop-up menu allows players to choose their desired weapon from a visually appealing selection. Activated by pressing the tab key, the weapon wheel provides a convenient way to switch between different weapons without the need for complex hotkey combinations or potentially problematic scroll wheel controls. By selecting a specific weapon, such as the sword or gun, players can easily equip their desired tool for combat. To enhance the visual experience, we made the character's hands invisible when no weapon is equipped, preventing any visual inconsistencies. This addition not only improves the overall look of the game but also ensures a smoother gameplay experience. With the weapon wheel system in place, players can now fully utilize and enjoy the available arsenal of weapons.
Implementing a Dash Ability
Seeking to expand the gameplay mechanics, we decided to reintroduce the dash ability into the game. As dash abilities can greatly enhance player movement and strategic options, we believed it would be a valuable addition to our project. However, due to technical constraints with the character controller, we had to adapt our approach to implementing the dash. Instead of adding force in a specific direction, we utilized the player's facing direction to move them forward relative to their position. While this method did introduce some minor timing adjustments to ensure smooth animation transitions, we managed to create a dash ability that not only looks visually pleasing but also adds an extra layer of excitement to the gameplay. To enhance the dash effect and make it more visually appealing, we incorporated particle effects and a post-processing volume that dynamically adjusts based on the player's dashing state. With this dash ability implemented, players can now swiftly navigate through the game world and engage in thrilling combat encounters.
Introducing Enemies
To further enhance the gameplay experience and provide players with a challenge, we turned our attention to the implementation of enemies. While our previous attempts at utilizing an AI system proved to be inefficient, we decided to start from scratch and create an enemy AI system that better suited our needs. Using Blender, we created a simple enemy model by modifying an existing character model downloaded from the internet. After rigging the model and importing it into Unity, we focused on breathing life into these enemies.
Creating a Robot Model
Before implementing enemy AI, we needed a suitable character model for the enemies. With the intent to create a main soldier robot enemy, we utilized Blender to develop a basic model. While the aesthetics of the model were not our primary focus at this stage, we created a model that combined existing elements with custom-made parts, resulting in a functional enemy character. This approach allowed us to save time and maintain flexibility for future refinements.
Implementing AI for the Enemies
To create engaging and intelligent enemies, we knew our AI system had to be robust and flexible. While searching for the best approach, we stumbled upon a Tutorial that showcased the Unity Nav Mesh Agent, a powerful tool that handles movement and pathfinding. Despite following the tutorial, we realized that the default AI system did not meet our requirements, as we wanted our enemies to exhibit physics-based movement instead of static navigation. Additionally, we wanted to use animations to bring the enemies to life and make their behavior more organic. After experimenting with different methods, we found a way to combine the Unity Nav Mesh pathfinding with physics-based movement. By recalculating the path frequently, we ensured that the enemies were always moving towards the player's position while dynamically adjusting their path to avoid obstacles. This implementation allowed us to create enemies that feel more realistic and challenge players in a more immersive manner.
Adding Animations for the Enemies
To create a more immersive and visually appealing gameplay experience, we integrated animations for the enemies. Using Mixamo, we obtained walking animations and manually created idle and attack animations. With the animations set up within Unity, the enemies now have a more natural and fluid movement. Additionally, we ensured that the enemies always face the player, enhancing the sense of them actively pursuing their target. To further enhance the combat experience, we added reaction animations for when the enemies take damage. These animations, along with sound effects and a slowdown effect, make defeating enemies feel more satisfying and impactful.
Setting up Damage Logic for the Enemies
To create a more balanced and challenging combat system, we implemented damage logic for the enemies. When a player attacks an enemy with a pistol, we used a Raycast to detect if the enemy was hit and applied damage accordingly. For close-range combat with a sword, we utilized trigger detection to determine if the enemy was hit. This logic enabled us to create distinct gameplay mechanics for different weapons and provided players with various strategic options. To add more depth to the combat experience, enemies also enter a stun state when they are hit, further emphasizing the impact of the player's attacks. By incorporating sound effects and visual effects such as slow motion, we aimed to create an immersive and satisfying combat encounter.
Conclusion
In this episode, we focused on expanding the gameplay mechanics and introducing enemies to the game. By adding more weapons, implementing a weapon wheel, and creating a dash ability, we enhanced the variety and strategic options available to players. Furthermore, we created a robot model for the enemies and developed a robust AI system that combines pathfinding with physics-based movement. With the addition of animations and damage logic, we aimed to create a more engaging and immersive combat experience. While there are still areas to refine, we have made significant progress in creating a dynamic and challenging gameplay experience for our players.