Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

Difference between revisions of "movetogoal"

From Quake Wiki

m (Usage)
Line 5: Line 5:
  
 
If an entity can fly or swim, it will attempt to level itself with its enemy, not the goal entity. If it can't fly or swim and is off the ground, it won't move at all. If an entity is too close to its goal it'll also stop moving.
 
If an entity can fly or swim, it will attempt to level itself with its enemy, not the goal entity. If it can't fly or swim and is off the ground, it won't move at all. If an entity is too close to its goal it'll also stop moving.
 +
 +
'''Warning:''' The function assumes that self is the current entity trying to move.
  
 
=== Parameters ===
 
=== Parameters ===

Revision as of 17:14, 1 August 2023

void movetogoal(float dist)

Usage

Attempts to move an entity towards its goalentity field. This function only supports movement in 8 directions (North, Northeast, East, Southeast, South, Southwest, West, and Northwest). If the entity's movement is blocked it will try and redirect itself to keep moving towards its goal. Movement is only done on the x and y axes. This does not sweep the movement area so large steps should be broken down into smaller parts, otherwise missed collisions can occur.

If an entity can fly or swim, it will attempt to level itself with its enemy, not the goal entity. If it can't fly or swim and is off the ground, it won't move at all. If an entity is too close to its goal it'll also stop moving.

Warning: The function assumes that self is the current entity trying to move.

Parameters

  • dist
How far the entity should move in map units.

Example

// Slow down movement as the monster gets closer to its enemy
float multi = enemy_range / RANGE_MID;
if (multi < 0.5)
    multi = 0.5;
else if (multi > 1)
    multi = 1;

movetogoal(32 * multi);