Vector3 UpdateMove( Rotation eyes, Vector3 input )

book_4_sparkGenerated
code_blocksInput

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 is typically used in character movement systems to determine how the character should move based on the current input and orientation.

Usage

To use the UpdateMove method, you need to override it in a derived class of MoveMode. This method takes two parameters:

  • eyes: A Rotation object representing the current orientation of the character's view or eyes.
  • input: A Vector3 object representing the input direction, typically derived from user input such as keyboard or controller input.

The method returns a Vector3 representing the desired velocity based on the input and orientation.

Example

public class CustomMoveMode : MoveMode
{
    public override Vector3 UpdateMove(Rotation eyes, Vector3 input)
    {
        // Example implementation: Calculate the wish velocity based on input and orientation
        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;
    }
}