s&box
RustCounter-Strike 2s&boxDeadlock
Wiki
Get s&box on Steam
Browse
OverviewGetting StartedCreating GamesEngine & ToolsDocumentationCommunity GamesResources
s&boxDocumentationSceneComponentsComponent Interfaces
SOURCE 2 · C#
Build and play games with s&box.

Facepunch's game engine and creation platform — make games in C#, or jump straight into community games.

Get s&box on Steam

s&box Wiki

  • Overview
  • Getting Started
  • Creating Games
  • Engine & Tools
  • Documentation
  • Community Games
  • Resources

Tools & Community

  • Getting Started
  • Creating Games
  • Engine & Tools
  • Resources

Platforms

  • RustBattle
  • CSBattle
  • Rust Game Wiki
  • CS2 Skins Wiki
  • Deadlock Wiki

About

  • Official Site
  • Developer Wiki
  • GitHub
  • Get on Steam
NOT AFFILIATED WITH FACEPUNCH STUDIOS · © 2026 s&box Wiki (community)
Docs/Scene
Scene

Component Interfaces

There are various interfaces that can be given to components for specific purposes.

A component marked with ExecuteInEditor will also execute these methods in edit mode:

  • OnAwake
  • OnEnabled
  • OnDisabled
  • OnUpdate
  • OnFixedUpdate

Sample code

public sealed class ExecuteInEditorSample : Component, Component.ExecuteInEditor
{
	protected override void OnEnabled()
	{
		base.OnEnabled();

		if ( Game.IsEditor )
		{
			Log.Error( "OnEnabled is also executed in editor" );
		}
	}
}

A component with this interface can react to physics collisions.

MethodDescription
OnCollisionStartCalled when this collider/rigidbody starts touching another collider.
OnCollisionUpdateCalled once per physics step for every collider being touched, while the collision is awake. Sleeping contacts don't send updates - use Collider.Touching to track resting contacts.
OnCollisionStopCalled when this collider/rigidbody stops touching another collider.

Sample code

public sealed class CollisionListenerSample : Component, Component.ICollisionListener
{
	public void OnCollisionStart( Collision other )
	{
		Log.Error( "Collision started with: " + other.Other.GameObject );
	}

	public void OnCollisionUpdate( Collision other )
	{
		Log.Error( "Collision continued with: " + other.Other.GameObject );
	}

	public void OnCollisionStop( CollisionStop other )
	{
		Log.Error( "Collision stopped with: " + other.Other.GameObject );
	}
}

A component with this interface can react to trigger interactions.

MethodDescription
OnTriggerEnterCalled when a collider enters the trigger.
OnTriggerExitCalled when a collider stops touching the trigger.

Sample code

public sealed class TriggerListenerSample : Component, Component.ITriggerListener
{
	public void OnTriggerEnter( Collider other )
	{
		Log.Error( "Trigger entered with: " + other.GameObject );
	}

	public void OnTriggerExit( Collider other )
	{
		Log.Error( "Trigger exited with: " + other.GameObject );
	}
}

A helper interface to mark components that can be damaged by something.

MethodDescription
OnDamageThe method you invoke when damaging something marked with IDamageable

Sample code

public sealed class SampleDamageable : Component, Component.IDamageable
{
	public void OnDamage( in DamageInfo damage )
	{
		Log.Error( $"I got damaged for {damage.Damage} by {damage.Attacker}" );
	}
}
public sealed class ClickToDamage : Component
{
	protected override void OnUpdate()
	{
		base.OnUpdate();

		if ( Input.Pressed( "attack1" ) )
		{
			var ray = Components.Get<CameraComponent>().ScreenPixelToRay( Mouse.Position );
			var trace = Scene.Trace.Ray( ray, 5000f ).Run();
			if ( trace.Hit )
			{
				var damageable = trace.GameObject.Components.Get<IDamageable>();

				if ( damageable != null )
				{
					damageable.OnDamage( new DamageInfo()
					{
						Damage = 12,
						Attacker = GameObject,
						Position = trace.HitPosition,
					} );
				}
			}
		}
	}
}

A component with this interface can react to 📆 Network Events.

A component with this interface can react to 📆 Network Events

Source: Facepunch/sbox-docs (CC-BY-4.0) · updated 2026-01-11. Read it rendered on the official docs.

More in Scene

Advanced Topics
Async
Camera Effects
Component Methods
Component Versioning
Components
Events
Execution Order
← All documentation

Community wiki — not affiliated with Facepunch Studios. For the latest and most authoritative information, see the official developer wiki.