Devlog: 15 September 2024 – Improving Interactions: Treasure Chest and Arrow Shooting


Objective: Today’s focus was on two key features of my Gauntlet-style game: refining the treasure chest interaction and enhancing the player’s arrow-shooting mechanics. The goal was to ensure both interactions felt smooth and responsive, improving the overall player experience.

Progress Made:

1. Treasure Chest Interaction Improvements

The treasure chest interaction was my first task of the day. I aimed to make it easier for the player to open the chest with the E key when they were nearby, without requiring constant movement. Initially, the chest opened only when I moved directly against it and pressed E, which felt clunky.

Key Changes:

  • Animator Setup: I successfully re-created the opening animation for the treasure chest. The chest smoothly transitions from closed to partially open and then fully open using a newly set up animation clip. I ensured that this animation didn’t loop indefinitely by tweaking the transitions in the Animator.
  • Responsive Key Press: To make the interaction more natural, I shifted from using OnTriggerStay2D to detect the player’s presence to handling the E key press in the Update() method. This approach allows for continuous input detection, ensuring that the player can open the chest without needing to keep moving.
  • Interaction Prompt: I added an optional visual cue—a prompt that displays when the player is near the chest, guiding them to press E to interact. This prompt disappears once the chest opens or the player leaves the area.

Challenges Solved:

  • Making the chest open more responsively was a key focus. By using OnTriggerEnter2D to detect the player's presence and continuously checking for key input in Update(), the interaction became smoother.

2. Arrow Shooting Mechanics

After finalising the treasure chest interaction, I worked on improving the arrow-shooting mechanics for the player’s character. This feature needed to feel fast and accurate, with arrows shooting in the direction the player is facing and being destroyed upon hitting enemies or walls.

Key Changes:

  • Direction and Firing: I refined the script so that the arrows now shoot in the correct direction based on the player’s orientation. The arrow’s facing direction adjusts depending on whether the player is moving north, south, east, or west, and the projectile's rotation matches the player's facing angle.
  • Rigidbody and Collisions: I added a Rigidbody2D to the arrows to handle their physics and ensure they travel smoothly. I also implemented collision detection using OnCollisionEnter2D, making sure that arrows are destroyed when they hit enemies.

Challenges Remaining:

  • While I resolved the arrow-enemy interactions, I’m still working on getting the arrows to interact correctly with walls. Currently, the arrows pass through walls instead of being destroyed on impact. I plan to continue refining the collider setup and investigate how to improve the wall-arrow interaction in the next session.

Combined Lessons Learned:

Working on both the treasure chest interaction and arrow mechanics today, I learned a lot about using triggers, colliders, and Rigidbody2D components to handle responsive gameplay interactions. In particular:

  • Using Update() for key detection ensures more responsive interaction than relying solely on OnTriggerStay2D.
  • Fine-tuning the collision layers and settings is essential for ensuring that objects interact properly in the game world.
  • Animation transitions need to be carefully managed to prevent looping issues and ensure smooth state transitions.

Next Steps:

  • Treasure Chest: I plan to expand on the treasure chest interaction by adding an item-reward system.
  • Arrow Shooting: Next, I want to work on fixing the wall-arrow interaction physics and refine the animation sequence.
  • General Interaction Improvements: I’ll continue refining the responsiveness of other interactions in the game to maintain a fluid player experience.

Overall Reflection: Today’s work significantly improved two core mechanics of the game. The treasure chest interaction now feels much more intuitive, and the arrow shooting mechanics are fast and accurate. However, there’s still work to be done on the wall interaction with arrows. Once that’s resolved, these mechanics will provide a smoother and more enjoyable experience for the player.

Leave a comment

Log in with itch.io to leave a comment.