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

Editing movetogoal

From Quake Wiki

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
''void'' '''movetogoal'''(''float'' dist)
+
====Syntax:====
 +
<code>void movetogoal(float dist)</code>
  
== Usage ==
+
This is the primary means of navigation available to monsters.  It is a very basic form of navigation consisting of only 2 behaviours:
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.
+
1. Move straight toward the current''' .goalentity'''
 +
2. If blocked, move in a random direction for a random period of time.
 +
If the monster has the '''FL_FLY''' flag set, it will try to stay slightly above the height of the entity in the '''.enemy''' field.
 +
====Parameters:====
 +
:<code>dist</code> - How far to 'step'.
 +
====Returns:====
 +
:void
 +
====Other Details:====
 +
Please note that the movement target and the height target are set via ''different'' fields. Setting '''.goalentity''' but not '''.enemy''' will result in a monster not adjusting it's height.
 +
However, merely setting '''.enemy''' to an entity is not enough for movetogoal to match heights with it.  The entity in the '''.enemy''' field must have a bounding box (it cannot be a point entity) and it must also have a '''.movetype''' other than '''MOVETYPE_NONE''').
  
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);
 
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Please note that all contributions to Quake Wiki are considered to be released under the GNU Free Documentation License 1.3 or later (see Quake Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)