static Vector3 Snap( Vector3 input, Vector3 movement )
static Angles Snap( Angles input, Angles movement )

book_4_sparkGenerated
code_blocksInput

Description

The Snap method in the Gizmo class is a static method used to adjust a given vector to align with a specified movement vector. This is typically used in scenarios where you want to snap an object's position to a grid or a specific alignment in 3D space.

Usage

To use the Snap method, you need to provide two Vector3 parameters:

  • input: The original vector that you want to adjust.
  • movement: The vector that defines the snapping increments or the grid alignment.

The method returns a new Vector3 that represents the snapped position.

Example

// Example usage of the Gizmo.Snap method
Vector3 originalPosition = new Vector3(1.3f, 2.7f, 3.5f);
Vector3 gridSize = new Vector3(1.0f, 1.0f, 1.0f);

Vector3 snappedPosition = Gizmo.Snap(originalPosition, gridSize);
// snappedPosition will be (1.0f, 3.0f, 3.0f) assuming the Snap method rounds to the nearest grid point.