Class CarriedLight
A light a character carries, held a little ahead of the shoulder so the walls, the floor and the faces in front of them read in a cave the sky never reaches.
[DisallowMultipleComponent]
public sealed class CarriedLight : MonoBehaviour
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourCarriedLight
- Inherited Members
-
MonoBehaviour.IsInvoking()MonoBehaviour.CancelInvoke()MonoBehaviour.StopCoroutine(Coroutine)MonoBehaviour.StopAllCoroutines()MonoBehaviour.destroyCancellationTokenMonoBehaviour.useGUILayoutMonoBehaviour.didStartMonoBehaviour.didAwakeMonoBehaviour.runInEditModeBehaviour.enabledBehaviour.isActiveAndEnabledComponent.GetComponent<T>()Component.TryGetComponent<T>(out T)Component.GetComponentInChildren<T>()Component.GetComponentsInChildren<T>()Component.GetComponentInParent<T>()Component.GetComponentsInParent<T>()Component.GetComponents<T>()Component.GetComponentIndex()Component.CompareTag(TagHandle)Component.transformComponent.transformHandleComponent.gameObjectComponent.tagObject.GetEntityId()Object.GetInstanceID()Object.GetHashCode()Object.InstantiateAsync<T>(T)Object.InstantiateAsync<T>(T, Transform)Object.InstantiateAsync<T>(T, Vector3, Quaternion)Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Scene)Object.Instantiate<T>(T, InstantiateParameters)Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectsByType<T>(FindObjectsSortMode)Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)Object.FindObjectOfType<T>()Object.FindFirstObjectByType<T>()Object.FindAnyObjectByType<T>()Object.FindFirstObjectByType<T>(FindObjectsInactive)Object.FindAnyObjectByType<T>(FindObjectsInactive)Object.FindObjectsByType<T>()Object.FindObjectsByType<T>(FindObjectsInactive)Object.ToString()Object.nameObject.hideFlags
Remarks
Brighter than the walls' torches. The cut's mine and cave-camp torches are lit by SiteLightPool at about 1.6 with a three-beat flicker and a warm orange, and its buried lamps at 2.2, steady: marks along a way, not light to see it by. A carried torch uses the same flicker and very nearly the same colour (a shade redder, nearer a pitch flame's 2200 K), but at the wall torches' strength it lit the rock within an arm's length and left the rest black in the cave walkthrough render (2026-10-13: "Ensure we can see and use the torch or a stronger light source for visual clarity"). URP point lights fall off with the square of distance whatever their range, so the strength is what carries: the torch reads the floor and walls a room's width off, the lantern most of a hall's. Underground the sky's ambient falls to under a tenth (SkySystem's darkness), so these are most of what lights a cave.
Ahead, not at the hand. Parented to what the character's model is drawn under (the smoothed graphical object, HolderFor(ICharacter)), not to a hand bone: an arm swinging through a walk would swing every shadow in the cave with it, and the race model under the mesh root is destroyed and rebuilt whenever it reloads. It sits forward of the chest at shoulder height, so the body's own shadow falls behind it (away from a camera that follows from behind), and the front of the character, not the back the camera sees, takes the light's hot near field.
One shadow. Soft shadows for at most one carried light at a time (the first lit takes them, and gives them up when it goes out): a shadowed point light renders six cube faces of every caster within its range, the cost SiteLightPool already pays for its nearest few indoor lights and no more. Where the quality tier has no additional-light shadows URP draws the light unshadowed and charges nothing for asking.
Presentation only, never simulation: a server never builds one. Attach(Transform, CarriedLightMode) works in edit mode too, so a render probe can hang the same light on its camera and see what a player sees; flicker only runs in play mode.
Fields
LanternColour
A lantern's candle behind glass, about 3000 K: a touch whiter than a buried lamp's (1, 0.72, 0.42).
public static readonly Color LanternColour
Field Value
- Color
LanternIntensity
The lantern's strength: twice the torch, steady, as a lantern's glass and shutter throw it forward.
public const float LanternIntensity = 12
Field Value
LanternRange
How far the lantern reaches, metres.
public const float LanternRange = 26
Field Value
ObjectName
The name of the child object the light lives on, so a holder's light can be found again.
public const string ObjectName = "Carried Light"
Field Value
TorchColour
A pitch flame, about 2200 K: a shade redder than the wall torches' (1, 0.66, 0.36).
public static readonly Color TorchColour
Field Value
- Color
TorchIntensity
The torch's mean strength: enough to see a room's floor and walls by, about four wall torches.
public const float TorchIntensity = 6
Field Value
TorchRange
How far the torch reaches before its falloff is windowed to nothing, metres.
public const float TorchRange = 14
Field Value
Properties
Mode
What is carried now.
public CarriedLightMode Mode { get; }
Property Value
Source
public Light Source { get; }
Property Value
- Light
Methods
Attach(Transform, CarriedLightMode)
Gives holder a carried light in mode, creating it on first use, and returns
the light (disabled for Off).
public static Light Attach(Transform holder, CarriedLightMode mode)
Parameters
holderTransformWhat carries it: a character's HolderFor(ICharacter), or a camera.
modeCarriedLightModeWhat to carry.
Returns
- Light
The light, or null when
holderis null.
Remarks
On a camera it is held low and right of the eye; on anything else it is held ahead of the shoulder, measured from the nearest capsule collider at or above the holder (a character's), or from a 1.8 m figure standing at the holder when there is none. Usable outside play mode: the light is lit at once at its mean strength, and the object is never saved with a scene.
Detach(Transform)
Removes holder's carried light, if it has one.
public static void Detach(Transform holder)
Parameters
holderTransform
Find(Transform)
The carried light directly under holder, or null.
public static CarriedLight Find(Transform holder)
Parameters
holderTransform
Returns
HolderFor(ICharacter)
The transform a character's light is parented to: the parent of its mesh root, which is the object FishNet smooths between ticks, so the light glides with the drawn model rather than stepping with the simulated root.
public static Transform HolderFor(ICharacter character)
Parameters
characterICharacterThe character; null gives null.
Returns
- Transform
Next(CarriedLightMode)
The next mode the cycle key steps to: Off, Torch, Lantern, and round again.
public static CarriedLightMode Next(CarriedLightMode current)
Parameters
currentCarriedLightMode
Returns
SetMode(CarriedLightMode)
Changes what is carried, lighting or putting out the light at once.
public void SetMode(CarriedLightMode value)
Parameters
valueCarriedLightMode