Pathing Over Objects

So im trying to think of the easiest way to modify the default AStarAi script to get the AI to climb over obstacles.

I tried shooting a ray out in front of me, and if it detects a hit to instead try climbing up instead of going forward towards the next waypoint dir but am having some issues.

Something like how bugs would work, if theres a rock or a brick in their way they arent going to go around it, their going to path up and over the top to get where their going.

Oh and the wall walking code i was looking at was the accepted answer from this thread.

The problem is it works with a rigidbody, so im trying to figure out how to do something similar by merging it and the AStar Pathfinding together to get the AI up and over objects.

Well… You might as well let the pathfinding put way points on top of the objects… I will make this easier :stuck_out_tongue:

A simple idea would be to give your units 2 movement modes: climbing, and walking

Walking would only move on the X and Z axis: and would move towards the next waypoint~

Climbing would only move on the Y axis, and move at whatever the units climbing speed is~

Walking would be the default movement type:
On collisions with objects masked “obstacles”, the unit switch’s from Walking to Climbing:

When the units y axis = the next waypoints y axis, it go’s back to walking…

2 things to Note:
Vector3.normalized is super useful when editing things~ It makes sure the magnitude of the vector is 1, letting you keep a constant movement speed:
Read more here!!

Also, when Climbing you want to make sure that it ends exactly at the same point as the next waypoints y axis: there are a number of ways to do this so its worth a google :slight_smile:

Edit: also note that at the time of writing this i am really tired, and burnt, and everything… So if it ends up making any sense, it was probably a mistake