pixelatedcrown

my testing method of “put a bunch of em down, see what goes wrong then try and fix it” is working pretty well, even if it looks like chaos.

this is my third version of a way to move AI - first I tried using unity’s built in pathfinding but that wouldn’t work for procedural environments. then I tried using the A* pathfinding project for unity, which is free and good! but overall too much for what I need. so I decided to just write what I needed myself, as well as giving playmaker a go (which I never have before, and it seems very useful and good!).

there’s a fair bit going on here but the simple simple version is:
- an AI gets a new position in front of it (newPos) by a set distance (jumpDistance)
- newPos is re-positioned to match the height of the ground above or below it
- if newPos is behind or in front of something else by the width of the AI’s model, reposition newPos to be in front of it enough that the model won’t clip through it when moved to it
- some stuff making sure the peak of the jump is positioned above a rise so the model doesn’t clip through anything while moving to newPos, otherwise the peak of the jump is half way between the starting positon and newPos
- some other stuff making the peak of the jump be half way between the starting pos and the adjusted newPos if it was moved in front of something
- jump to newPos! move to the peak of the jump then back down to newPos
- check if there’s something in front of it’s new position, and if there is, try turning left, then right, then backwards. then start over by getting a new newPos!

this is all for if the player is not inside the same room as the AI - if they player is around then their newPos becomes jumpDistance towards the player’s position instead of directly in front of the AI, and they turn to face the player constantly so don’t need to do turn checks left/right/back when an obstacle is in front of them

I haven’t got them aligning to slopes yet so I’ll do that next!