Files
sbox-public/engine/Sandbox.Engine/Scene/GameObject/GameObject.WorldTransform.cs
Garry Newman d95169d8fa Unit Test Cleanup (#5064)
* Move all unit tests to Engine/Tests
* Fix Margin.EdgeSubtract
* Fix Capsule.Contains
* EnvironmentVariables.Remove if it's null
* Fixed ray trace never returning startedsolid
* Fix HistoryList.Navigate on empty list
* Fix GameObject.WorldPosition accepting NaNs
* Fix flex: initial expanding to the wrong grow/shrink
* Translation.TryConvert shouldn't throw on invalid enum strings
* Skip sound file tests on machines with no audio device
2026-06-12 13:23:50 +01:00

54 lines
1.3 KiB
C#

namespace Sandbox;
public partial class GameObject
{
/// <summary>
/// The world transform of the game object.
/// </summary>
[ActionGraphInclude, Group( "Transform/World" )]
public Transform WorldTransform
{
get => _gameTransform.World;
set => _gameTransform.World = value;
}
/// <summary>
/// The world position of the game object.
/// </summary>
[ActionGraphInclude, Group( "Transform/World" )]
public Vector3 WorldPosition
{
get => WorldTransform.Position;
set
{
// Same guard the old Transform.Position accessor had - a NaN position
// silently poisons the whole hierarchy, catch it at the source.
if ( value.IsNaN )
throw new System.ArgumentOutOfRangeException( nameof( value ), "Position is NaN" );
WorldTransform = WorldTransform.WithPosition( value );
}
}
/// <summary>
/// The world rotation of the game object.
/// </summary>
[ActionGraphInclude, Group( "Transform/World" )]
public Rotation WorldRotation
{
get => WorldTransform.Rotation;
set => WorldTransform = WorldTransform.WithRotation( value );
}
/// <summary>
/// The world scale of the game object.
/// </summary>
[ActionGraphInclude, Group( "Transform/World" )]
public Vector3 WorldScale
{
get => WorldTransform.Scale;
set => WorldTransform = WorldTransform.WithScale( value );
}
}