-
Notifications
You must be signed in to change notification settings - Fork 0
KAI_MoveTowards()
KAI_MoveTowards (Vector3 TargetPos[, Double DetourFactor = 1.0, Double AngleLimit = 10, Int ChaseFlags = 0, Int Flags = 0, Double PitchLimit = 40])
- TargetPos: The Vector3 coordinate that the actor should move towards.
- DetourFactor: How much the actor is allowed to move around an obstacle after hitting one, before beginning to head towards TargetPos again. Actors take 16 to 32 steps by default, this is a multiplier for that. Default is 1.0.
- AngleLimit: How wide of a turn in degrees the actor can take per step. A value of 0 makes the actor take instant 180 degree turns. Default is 10.
- ChaseFlags: What flags from A_Chase should the function use ? Supports CHF_DONTMOVE, CHF_NODIRECTIONTURN, CHF_NORANDOMTURN, and CHF_STOPIFBLOCKED.
- Flags:
- KMT_CHASEGOAL: If the caller has a goal pointer, and the bChaseGoal flag on. It will follow the goal instead of the TargetPos.
- KMT_ZIGZAG: Causes the NPC to zig-zag when moving around, in a manner similar to KAI_MoveTowards() and A_Chase. Instead of moving towards the TargetPos in a straight line.
- KMT_NOLINEUSE: The NPC will not use any monster push and use lines it collides with. This can be used to allow monsters to run their own line use code.
- KMT_3D: Make the actor take a flying movement step. This is the flag you pass if you want the actor to fly around instead of walking along the ground.
- PitchLimit: Same as AngleLimit, but for the actors' pitch. Used by KMT_3D to define a vertical turn speed.
- None
Makes the NPC move to TargetPos. This is THE main movement function for KAI NPCs, all other built-in functions use this to move, and are basically wrappers for it. The function also supports the +CANTLEAVEFLOORPIC flag, treating sectors with different floor textures as obstacles, and using monster pushable and usable lines.
Important
The vanilla +FLOAT logic has a code snippet that adjusts the height of floaters to match their targets' height. This snippet can only be turned off with the +INFLOAT flag, which KMT_3D turns on with every "step" already. Because this piece of logic runs every tick (It's part of the movement of ALL actors instead of AI code for some ungodly reason), you should also make sure to turn the flag on in your actors' Default{} block. It can also be unset from successful TryMove() calls, so keep that in mind.
By default, KMT is meant for 2D ground based movement, and works by calling TryMove() to move the actor to TargetPos. The KMT_3D flag completely changes point-to-point movement, by making the function actually propel the actor in 3D space towards TargetPos, allowing them to fly around like how +FLOAT works with the vanilla GZDoom movement.
KMT_3D propels the actor to the destination while also enforcing a speed limit to how fast they can move, it roughly matches the actors' Speed property, so a speed of 8 means that the actor will always try to stick to a total velocity of ~8. Shedding away any external forces and also generally making sure the actor doesn't accelerate at hyperspeed towards the destination.
In addition to the general speed cap, the function also slows the actor based on how far their velocity is taking them AWAY from the destination, so for example if they are still turning to face the target, they will slow down a bit until they more or less fully face it, but if something like an explosion begins blasting them away from their destination, they'll rapidly slow down so that they can continue moving towards it.
If the actor bumps unto something that they can climb over or under. They will use KMT_3D_ScaleObstacle, which behaves like the built-in +FLOAT logic, but better. If the scalable obstacle is a raised floor, it will climb up, if it's a lowered ceiling, it does the opposite. But if it's an obstacle with both a top AND bottom, like a 3D floor, 3D middle texture, or other blocking actor, it will check which side it's already closer to, and begin moving there. It also makes sure that neither side is blocked, if for example it hit a TechLamp on the ground, it'll just go up because the underside is blocked. If both sides of an obstacle with a top and bottom are blocked (Such as an actor as tall as the ceiling or with too small an opening to get through), then it's treated as a fully blocking obstruction like a wall. KMT_3D then moves the actor up or under the obstacle using its' FloatSpeed property, just like in vanilla.
When the actor bumps into something along the way that it can't climb, it will bounce off it using the same A_Chase() style logic as in 2D ground mode.
This Pinky does nothing besides follow the first enemy it sees and play its' active sound.
Class FollowerPinky : KAI_Creature
{
Default
{
Health 150;
PainChance 180;
Speed 10;
Radius 30;
Height 56;
Mass 400;
Monster;
+FLOORCLIP
SeeSound "demon/sight";
AttackSound "demon/melee";
PainSound "demon/pain";
DeathSound "demon/death";
ActiveSound "demon/active";
Obituary "$OB_DEMONHIT";
Tag "$FN_DEMON";
}
States
{
Spawn:
SARG AB 10 A_Look;
Loop;
See:
SARG AABBCCDD 2 Fast
{
If (Target)
KAI_MoveTowards(Target.Pos,detourfactor:0.5);
KAI_Chase_HandleActiveSound(0);
}
Loop;
}
}
- Home
- Features
- Classes
- Functions
- Guides