S&box Wiki

Sandbox.Entity.Spawn

Syntax

void Spawn()

Example

Create a simple prop with a tree model and spawn it where the player is looking.

var eyePos = Owner.EyePosition; var eyeRot = Owner.EyeRotation; var trace = Trace.Ray( eyePos, eyePos + eyeRot.Forward * 800 ) .Ignore( Owner ); var tr = trace.Run(); if ( tr.Hit && tr.Entity.IsWorld ) { Prop prop = new Prop(); prop.Position = tr.HitPosition; prop.SetModel( "models/sbox_props/trees/oak/tree_oak_small_a.vmdl" ); prop.Spawn(); // Delete the prop after 30sec prop.DeleteAsync( 30 ); }