Updating a Character’s Rotation To Avoid Obstacles

Updated on February 28, 2018 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
0 on February 28, 2018

Hi Brackeys,


I’m running into an issue with updating my rotation with a navmesh to avoid obstacles. I used the RPG Enemy AI tutorial as my reference and have used: 


Quaternion lookRotation = Quaternion.LookRotation(enemyToHero);
m_agent_local.transform.rotation = Quaternion.Slerp(m_agent_local.transform.rotation, lookRotation, Time.deltaTime * 10f);


And without an obstacle it updates the rotation correctly. However, this doesn’t take into consideration carved objects or the navmesh agent’s obstacle avoidance and I want to integrate that. Right now my character’s locomotion is driven with animation to update it’s position, but I want to use the navmesh to update it’s rotation. Any help would be greatly appreciated!

  • Liked by