Rotation and IsWalkable issue

I finished the course and I have a problem that the hex grid does not detect if there is a unit on it and it passes through the given unit.
Also, if you only have to go straight between two points, the character doesn’t turn around, it just walks backwards.
I also looked at the commits, but I can’t find where the error might be.

The unit should be able to walk through other units, that is the intended behaviour, it just should not be able to stop on top of another position but walking through it is intended.

If you don’t want that then you need to make the position under each unit as unwalkable. Look at the logic on the Unit script for keeping track of when the unit moves, where it’s updating the LevelGrid GridPosition, and in that same place add logic to tell the Pathfinding to make the previous node walkable and the next one unwalkable.

For the rotation, that’s because the rotation code uses Lerp, which interpolates a regular vector so when doing a 180 the vector becomes smaller and smaller until it suddenly flips, to fix it swap it for Slerp which interpolates a vector as a direction.

1 Like

Hallo@CodeMonkey!

Thank you very much for your help. Everything’s work perfectly. :slight_smile: .

My mistake because I thought I missed something and this action an issue.

I would like to thank you for this course, I really enjoyed it and learned a lot from it.
I hope there will be bonus lessons in the future

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms