-
Notifications
You must be signed in to change notification settings - Fork 0
Movement functions
The KAI library contains a handful of movement functions that use largely custom movement code instead of NewChaseDir(). They are shared by all NPCs. All three of these functions have their own pages:
In addition to the basic functions above. KAI_MoveTowards() uses these sub-functions when in KMT_3D mode, which handle different aspects of the NPCs point-to-point flight. These functions can also be used if you want to entirely write your own custom flying logic.
- Where: The coordinate to check at to see if there's an obstacle that can be scaled.
- TargetZ: The Z height the flyer should go to to scale the obstacle, this variable is passed by reference, so you should put a double variable in it and then see what the function set it to.
- Returns if the actor even has anything it can scale. This should also be checked for custom flyer climb logic, to make sure it doesn't enter a loop of scaling nothing just because TargetZ is valid.
Returns a position by reference that the actor can move up or down too. If the blocker at Where has only a top or bottom, it'll just go there. If the blocker has both (i.e another actor or a 3D floor), it will check if both are reachable, and pick the closest, if only one side is reachable (i.e the blocking actor is sitting on the floor), it will only return the reachable side to TargetZ. If the blocker can't be scaled at all, it will return false.
- Where: What position are we checking for blockage?
- IgnoreCeiling: Makes the function return true (Position NOT blocked) even if the actor is bumping at the ceiling at Where, hacky way to make KMT_3D not cause the actor to repeatedly try to change direction because it's bumping against the ceiling.
Returns true if the caller is blocked at Where. Used by KMT_3D movement and some of the other KMT_3D_* sub-functions to check where the flyer can and can't go.
- TargetPos: The position we're actually trying to head to.
- Returns a factor for how much to slow down the actor every KMT_3D step.
Used by KMT_3D to make the actor slow down every step based on how much their current velocity is facing away from the target position, the more it faces away, the closer to 0 the value is. This is used by the stock flying movement to make flyers slow down over time when blasted away from their destination, so they can resume heading to it.
- SpeedLimit: The rough max speed the actors' velocity vector can reach in length.
- ExtraVel: The velocity we want to add on top of the actors' existing velocity.
This function is what KMT_3D actually uses to make the actor fly from point to point. Besides just slapping ExtraVel on top of Vel. It also handles limiting the overall velocity of the actor by slowing it down. Ensuring the actor won't fly around too fast, such as accelerating to insane speeds over time so that it can reach whatever destination.
- Home
- Features
- Classes
- Functions
- Guides