codeAPI Reference
Sandbox.Angles
Sandbox.Angles
Euler angles (yaw, pitch, roll) representation.
Overview
Angles stores rotation as yaw, pitch, and roll in degrees — easier to work with than quaternions for many cases.
Creation
CSHARP
// Constructor
Angles ang = new Angles(yaw, pitch, roll);
// Individual components
Angles ang = new Angles { yaw = 90f, pitch = 45f, roll = 0f };Components
Common Values
CSHARP
Angles forward = new Angles(0, 0, 0);
Angles right = new Angles(90, 0, 0);
Angles up = new Angles(0, 90, 0);
Angles back = new Angles(180, 0, 0);Conversions
CSHARP
// To Rotation
Rotation rot = angles.ToRotation();
// From Rotation
Angles angles = rot.Angles();
// To Vector3 (direction)
Vector3 dir = angles.Forward;Normalization
CSHARP
// Wrap angles to standard ranges
Angles normalized = angles.Normal;
// Just yaw
float yaw = angles.yaw.Normal;Operations
CSHARP
Angles a = new Angles(10, 20, 0);
Angles b = new Angles(5, 5, 5);
// Addition
Angles sum = a + b; // (15, 25, 5)
// Subtraction
Angles diff = a - b; // (5, 15, -5)
// Scaling
Angles scaled = a * 2f; // (20, 40, 0)Interpolation
CSHARP
// Lerp angles
Angles smooth = Angles.Lerp(from, to, 0.5f);
// With wrapping
Angles shortWay = Angles.Lerp(from, to, 0.5f, true);Input to Angles
CSHARP
// Mouse look
var look = Input.AnalogLook;
EyeAngles += new Angles(look.y, look.x, 0) * Sensitivity;Property Usage
CSHARP
[Property, Range(-90, 90)]
public Angles SpawnAngles { get; set; }
Was this helpful?