Surfaceclass

A physics surface. This is applied to each PhysicsShape and controls its physical properties and physics related sounds.

object→GameResource→Surface
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public class Sandbox.Surface : Sandbox.GameResource

Constructors1

Showing 1 constructors

Methods12

Showing 12 methods

protected virtual Sandbox.Bitmap CreateAssetTypeIcon(int width, int height)PROTECTEDVIRTUAL

ParameterTypeDescription
widthint—
heightint—
Returns:Bitmap—

public static Sandbox.Surface FindByName(string name)PUBLICSTATIC

Returns a Surface from its name, or null

Note

Uncached mounted paths load synchronously and must be resolved on the main thread.

ParameterTypeDescription
namestringThe name of a surface property to look up
Returns:SurfaceThe surface with given name, or null if such surface property doesn't exist

public Sandbox.Surface GetBaseSurface()PUBLIC

Returns the base surface of this surface, or null if we are the default surface.

Returns:Surface—

public bool HasAllTags(string[] tags)PUBLIC

Do we have all the tags on this hitbox?

ParameterTypeDescription
tagsstring[]—
Returns:boolTrue if all tags match, false if any tag does not match.

public bool HasAnyTags(string[] tags)PUBLIC

Do we have all the tags on this hitbox?

ParameterTypeDescription
tagsstring[]—
Returns:boolTrue if any tag matches, false if all tags do not match.

public bool HasTag(string tag)PUBLIC

Do we have a tag?

ParameterTypeDescription
tagstring—
Returns:bool—

protected virtual void OnDestroy()PROTECTEDVIRTUALLIFECYCLE

Returns:void—

public Sandbox.GameObject PlaceSplatter(Vector3 position, Vector3 direction, Sandbox.GameObject hitObject = null)PUBLIC

Draw this surface's `Sandbox.Surface.Splatter`, traced from `position` along provided `direction`, ignoring `hitObject`, and put a decal where it lands, if there's any traceable surface within given distance. Total splatter count depends on the max amount of decals limit.

ParameterTypeDescription
positionVector3Where the hit landed.
directionVector3The direction the hit was travelling.
hitObject = nullGameObjectWhat was hit, which the trace passes through. Its whole model for a ragdoll.
Returns:GameObjectThe decal's GameObject, or null if none was placed.

public Sandbox.SoundHandle PlayCollisionSound(Vector3 position, float speed = 320)PUBLIC

Play a collision sound based on this shape's surface. Can return null if sound is invalid, or too quiet to play.

ParameterTypeDescription
positionVector3—
speed = 320float—
Returns:SoundHandle—

protected virtual void PostLoad()PROTECTEDVIRTUAL

Returns:void—

protected virtual void PostReload()PROTECTEDVIRTUAL

Returns:void—

public void SetBaseSurface(string name)PUBLIC

Sets the base surface by name.

ParameterTypeDescription
namestring—
Returns:void—

Properties20

Showing 20 properties

public string Sandbox.Surface.BaseSurface { get; set; }PUBLICGETSET

Filepath of the base surface. Use SetBaseSurface and GetBaseSurface.

Returns:string—

public float Sandbox.Surface.BounceThreshold { get; set; }PUBLICGETSET

Velocity threshold, below which objects will not bounce due to their elasticity.

Returns:float—

public float Sandbox.Surface.Dampening { get; set; }PUBLICGETSETOBSOLETE

Obsolete: This API member is obsolete.

Returns:float—

public float Sandbox.Surface.Density { get; set; }PUBLICGETSET

Density of this surface material. This affects things like automatic mass calculation. Density is in kg/m^3.

Returns:float—

public string Sandbox.Surface.Description { get; set; }PUBLICGETSET

A concise description explaining what this surface property should be used for.

Returns:string—

public float Sandbox.Surface.Elasticity { get; set; }PUBLICGETSET

Controls bounciness.

Returns:float—

public float Sandbox.Surface.FluidAngularDrag { get; set; }PUBLICGETSET

Angular drag applied when submerged.

Returns:float—

public float Sandbox.Surface.FluidLinearDrag { get; set; }PUBLICGETSET

Linear drag applied when submerged.

Returns:float—

public float Sandbox.Surface.Friction { get; set; }PUBLICGETSET

Friction of this surface material.

Returns:float—

public int Sandbox.Surface.Index { get; set; }PUBLICGETSET

Returns:int—

public uint Sandbox.Surface.NameHash { get; set; }PUBLICGETSET

Returns:uint—

public float Sandbox.Surface.RollingResistance { get; set; }PUBLICGETSET

Controls how easily rolling shapes (sphere, capsule) roll on surfaces.

Returns:float—

public Sandbox.Surface.OldSoundData Sandbox.Surface.Sounds { get; set; }PUBLICGETSETOBSOLETE

Sounds associated with this surface material.

Obsolete: This API member is obsolete.

Returns:OldSoundData—

public Sandbox.Surface.SplatterData Sandbox.Surface.Splatter { get; set; }PUBLICGETSET

Decals drawn behind hits on this surface. See `Sandbox.Surface.PlaceSplatter(Vector3,Vector3,Sandbox.GameObject)`.

Returns:SplatterData—

public string Sandbox.Surface.Tags { get; set; }PUBLICGETSET

A list of tags as one string.

Returns:string—

On this page

Constructorspublic Surface()Methodsprotected virtual Sandbox.Bitmap CreateAssetTypeIcon(System.Int32 width, System.Int32 height)public static Sandbox.Surface FindByName(System.String name)public Sandbox.Surface GetBaseSurface()public System.Boolean HasAllTags(System.String[] tags)public System.Boolean HasAnyTags(System.String[] tags)public System.Boolean HasTag(System.String tag)protected virtual System.Void OnDestroy()public Sandbox.GameObject PlaceSplatter(Vector3 position, Vector3 direction, Sandbox.GameObject hitObject = null)public Sandbox.SoundHandle PlayCollisionSound(Vector3 position, System.Single speed = 320)protected virtual System.Void PostLoad()protected virtual System.Void PostReload()public System.Void SetBaseSurface(System.String name)Propertiespublic Sandbox.AudioSurface Sandbox.Surface.AudioSurface { get; set; }public System.String Sandbox.Surface.BaseSurface { get; set; }public System.Single Sandbox.Surface.BounceThreshold { get; set; }public System.Single Sandbox.Surface.Dampening { get; set; }public System.Single Sandbox.Surface.Density { get; set; }public System.String Sandbox.Surface.Description { get; set; }public System.Single Sandbox.Surface.Elasticity { get; set; }public System.Single Sandbox.Surface.FluidAngularDrag { get; set; }public System.Single Sandbox.Surface.FluidLinearDrag { get; set; }public System.Single Sandbox.Surface.Friction { get; set; }public Sandbox.Surface.ImpactEffectData Sandbox.Surface.ImpactEffects { get; set; }public System.Int32 Sandbox.Surface.Index { get; set; }public System.UInt32 Sandbox.Surface.NameHash { get; set; }public Sandbox.Surface.SurfacePrefabCollection Sandbox.Surface.PrefabCollection { get; set; }public System.Single Sandbox.Surface.RollingResistance { get; set; }public Sandbox.Surface.ScrapeEffectData Sandbox.Surface.ScrapeEffects { get; set; }public Sandbox.Surface.SurfaceSoundCollection Sandbox.Surface.SoundCollection { get; set; }public Sandbox.Surface.OldSoundData Sandbox.Surface.Sounds { get; set; }public Sandbox.Surface.SplatterData Sandbox.Surface.Splatter { get; set; }public System.String Sandbox.Surface.Tags { get; set; }Metadata