-
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 at a (Roughly) 90 degree diagonal angle, the closer the to a diagonal angle there is, the fuller the extent of the actors' FlightDeceleration is used as a counterforce. In other words, the more it faces away, the stronger it brakes to course correct. The function also has a FlightWrongDirFactor multiplier for controlling the strength of this use of braking specifically. And can also be set to 0 to turn the function off. This is used by the stock flying movement to make flyers slow down over time to correct from flying away from the target (Such as when it moves or the caller is blasted away), 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. Instead of just slapping ExtraVel on top of Vel, it ensures that the composite velocity is not over the SpeedLimit, if it is, the ExtraVel is rounded down by 99% until it does not exceed the speed limit, being reduced to zero if needed. In addition, the function handles overall slowing the actor using FlightDeceleration if it's going too fast.
- Home
- Features
- Classes
- Functions
- Guides