void Move()

robot_2Generated
code_blocksInput

Description

The Move method is used to move a character based on its current velocity. This method is part of the CharacterController class, which allows for collision-constrained movement without the need for a rigidbody. The movement is not affected by external forces and will only occur when this method is explicitly called.

Usage

To use the Move method, ensure that the CharacterController component is attached to a GameObject. The method does not take any parameters and should be called within the game loop or in response to specific game events to update the character's position based on its velocity.

Example

// Example of using the Move method in a CharacterController
public class PlayerMovement : Sandbox.Component
{
    private CharacterController characterController;

    public override void Spawn()
    {
        base.Spawn();
        characterController = new CharacterController();
        // Initialize characterController properties if needed
    }

    public override void Simulate(Client client)
    {
        base.Simulate(client);

        // Set the velocity of the character
        characterController.Velocity = new Vector3(1, 0, 0); // Move right

        // Call the Move method to update the character's position
        characterController.Move();
    }
}