Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!
Difference between revisions of "movetogoal"
From Quake Wiki
(Created page with "====Syntax:==== <code>void movetogoal(float dist)</code> This is the primary means of navigation available to monsters. It is a very basic form of navigation consisting of o...") |
|||
Line 1: | Line 1: | ||
− | + | ''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 the | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | 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. | ||
+ | |||
+ | === 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); | ||
[[Category:QuakeC Function]] | [[Category:QuakeC Function]] |
Revision as of 17:13, 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.
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);