I want to have a flying NPC which can go up or down depending if the terrain is higher than up (the NPC levitates up) or if they are attacking ground NPCs (could just levitate) or other flying NPCs (below or higher than the NPC). The thing is, I dunno where to start, I tried using BodyVelocity and BodyPosition, it did not work out well as I expected. Would I use Cframe or would I use a modified version of pathfinding (using Y value) to get the NPC to fly.
EDIT: THIS QUESTION IS 10 DAYS OLD YET IT IS MODERATED BRUH

2 comments
Raycast from the NPC to the ground and use BodyPosition to move it to the designated Y value which is just the Y co-ordinate of the ground + the amount you want to hover.
I am not familiar with raycasting tho. I would just have to learn it.