Unity Rigidbody Motion Pt.2


The issue I was handling this week was the same as my previous one, getting a proper dodge to work for our player. As a recap, our roguelike game is intended to be a decent bit difficult, so there’s a reason to replay the game and improve your skills. But with difficulty, there should still be options for the player to use to survive dealing with enemies. That’s where a dodge would come into play but as of last week, I was still having issues getting the player to move in the correct direction and the correct distance. 

 After experimenting with multiple different methods, the raycast method mentioned last week proved to be what I needed. By shooting a raycast in front of the player, I can check if there’s anything in the player’s way within a set distance and pick a spot based on that information to act as a target. Past this point is where a slight concession had to be made as, applying force to the player’s rigidbody in a specific enough manner, proved to be too difficult of a task for me to handle. This means that a teleportation-like approach had to be taken instead. But, with the information the raycast gives access to, the rest of the process was simple. By making the raycast ignore what we want the player to be able to pass through and storing the position whenever the raycast hits anything else, we can get a suitable spot for the player to be teleported to with minimal issues. Add on visual details like a blink effect and a glowing trail, and the dodge is now able to avoid enemy attacks while still giving the user a suitable indication of where the player is. 

Author: Gilbert Pemberton 

Date: 3/28/2024

Get Suits of the Abyss

Leave a comment

Log in with itch.io to leave a comment.