Description
The UpdateMove
method is a virtual method in the MoveMode
class within the Sandbox.Movement
namespace. This method is responsible for processing input and returning the desired velocity, often referred to as "WishVelocity". It is designed to be overridden in derived classes to implement specific movement logic based on the player's input and orientation.
Usage
To use the UpdateMove
method, you need to have a class that derives from MoveMode
. Override this method to define how the movement input should be translated into a velocity vector. The method takes two parameters:
eyes
: A Rotation
object representing the player's current view direction.
input
: A Vector3
representing the movement input, typically from the player's input device.
The method returns a Vector3
that represents the desired movement velocity based on the input and orientation.
Example
public class CustomMoveMode : MoveMode
{
public override Vector3 UpdateMove(Rotation eyes, Vector3 input)
{
// Example logic to convert input into a velocity vector
Vector3 forward = eyes.Forward;
Vector3 right = eyes.Right;
// Calculate the wish velocity based on input
Vector3 wishVelocity = (forward * input.x) + (right * input.y);
// Normalize the velocity to ensure consistent speed
if (wishVelocity.Length > 1)
{
wishVelocity = wishVelocity.Normal;
}
return wishVelocity;
}
}