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

Difference between revisions of "walkmove"

From Quake Wiki

(Created page with "====Syntax:==== <code>float walkmove(float yaw, float dist)</code> Moves the entity referenced by self in the direction and distance specified. ====Parameters:==== :<code>yaw...")
 
Line 1: Line 1:
====Syntax:====
+
''float'' '''walkmove'''(''float'' yaw, ''float'' dist)
<code>float walkmove(float yaw, float dist)</code>
 
  
Moves the entity referenced by self in the direction and distance specified.
+
== Usage ==
====Parameters:====
+
Tries to move the entity in the given direction by the passed distance. This does not sweep the the entire movement area so large steps should be broken down into smaller parts, otherwise missed collisions can occur. This function only allows for manual movement on the x and y axes. By passing 0 for the distance it can be used to check the current position of the entity, allowing for manual collision detection.
:<code>yaw</code> - The direction that the entity will move in.
+
 
:<code>dist</code> - The distance that the entity will move in.
+
If the entity is not on the ground and cannot fly or swim, this will always fail. Note that for flying and swimming enemies, calling this will try and level them with their enemy.
====Returns:====
+
 
:Returns TRUE if the movement completed successfully, and FALSE if it did not.  The entity's position is reverted if the move is unsuccessful.
+
'''Warning:''' The function assumes that self is the current entity that's trying to move.
====Other Details:====
+
 
walkmove, unlike movetogoal, does not affect the entity's angles so, in the case of monsters, it causes them to slide around.
+
=== Parameters ===
Also unlike movetogoal, walkmove does not affect vertical position at all and will not match heights with enemies.
+
*''yaw''
 +
:The direction the entity wants to move. This is not relative to its current angle.
 +
*''dist''
 +
:The distance to try and move in map units.
 +
 
 +
=== Return ===
 +
Returns <code>TRUE</code> if the movement was successful.
 +
 
 +
== Example ==
 +
// This function will attempt to move towards a monster's enemy with a slight angle
 +
void SideSwipeAttack()
 +
{
 +
    if (!enemy_vis || enemy_range > RANGE_NEAR)
 +
        return;
 +
 +
    walkmove(enemy_yaw + 15, 20);
 +
    DoMeleeAttack();
 +
}
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Revision as of 12:02, 1 August 2023

float walkmove(float yaw, float dist)

Usage

Tries to move the entity in the given direction by the passed distance. This does not sweep the the entire movement area so large steps should be broken down into smaller parts, otherwise missed collisions can occur. This function only allows for manual movement on the x and y axes. By passing 0 for the distance it can be used to check the current position of the entity, allowing for manual collision detection.

If the entity is not on the ground and cannot fly or swim, this will always fail. Note that for flying and swimming enemies, calling this will try and level them with their enemy.

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

Parameters

  • yaw
The direction the entity wants to move. This is not relative to its current angle.
  • dist
The distance to try and move in map units.

Return

Returns TRUE if the movement was successful.

Example

// This function will attempt to move towards a monster's enemy with a slight angle
void SideSwipeAttack()
{
    if (!enemy_vis || enemy_range > RANGE_NEAR)
        return;

    walkmove(enemy_yaw + 15, 20);
    DoMeleeAttack();
}