Description
The UpdateMove
method is a virtual method in the MoveMode
class, which is part of the Sandbox.Movement
namespace. This method is responsible for processing input and returning the desired velocity, often referred to as "WishVelocity". It takes into account the player's current view direction and input vector to calculate the movement direction and speed.
Usage
To use the UpdateMove
method, you need to override it in a derived class of MoveMode
. This method should be called whenever you need to update the player's movement based on input. The method requires two parameters:
eyes
: A Rotation
object representing the player's current view direction.
input
: A Vector3
object representing the player's input direction and magnitude.
The method returns a Vector3
representing the calculated wish velocity based on the input and view direction.
Example
public class CustomMoveMode : MoveMode
{
public override Vector3 UpdateMove(Rotation eyes, Vector3 input)
{
// Example implementation: Calculate wish velocity based on input and view direction
Vector3 forward = eyes.Forward;
Vector3 right = eyes.Right;
// Calculate the wish direction
Vector3 wishDirection = (forward * input.x) + (right * input.y);
wishDirection = wishDirection.Normal;
// Calculate the wish velocity
float wishSpeed = input.z; // Assume input.z is the desired speed
Vector3 wishVelocity = wishDirection * wishSpeed;
return wishVelocity;
}
}