Table of Contents

Class RainSpout

Namespace
DFA.Puddlecraft

A point, or short outlet, that pours water in one direction, such as a drainpipe or gargoyle. The arc and landing point are traced in the editor, so no colliders are needed at runtime. The water itself is drawn by a RainSpoutEffects child (the Puddlecraft Spout Effects prefab).

The flow follows the water coming off the roof. With little water there is no pressure behind the outlet, so it dribbles off the lip as drops. As more water arrives, pressure builds and the water leaves faster and throws further, until a full flow follows the traced arc at full speed. As the roof drains, the flow eases back down to drips.

[ExecuteAlways]
[DisallowMultipleComponent]
[AddComponentMenu("Puddlecraft/Rain Spout")]
[Icon("Packages/com.dfa.puddlecraft/editor/icons/spout.png")]
public sealed class RainSpout : PuddlecraftBehaviour
Inheritance
RainSpout

Properties

alwaysOn

Pours at full flow whatever the weather.

public bool alwaysOn { get; set; }

Property Value

bool

arc

The baked arc of the stream, in world space, from the outlet to where it lands.

public IReadOnlyList<Vector3> arc { get; }

Property Value

IReadOnlyList<Vector3>

currentFlow

How much water is pouring right now: the flow rate times how much of the roof's water is running off (0 to 1). 1 is a normal flow, above 1 a heavier one.

public float currentFlow { get; }

Property Value

float

currentLanding

Where the water lands right now: closer in while it only dribbles, at the impact point at full pressure.

public Vector3 currentLanding { get; }

Property Value

Vector3

flowRate

Relative amount of water at full rain (0 or more). Scales the stream, splashes, ripples and sound.

public float flowRate { get; set; }

Property Value

float

hasImpact

True when the baked stream lands on a surface.

public bool hasImpact { get; }

Property Value

bool

impactNormal

Surface normal where the baked stream lands. Valid when hasImpact is true.

public Vector3 impactNormal { get; }

Property Value

Vector3

impactPoint

World position where the baked stream lands. Valid when hasImpact is true.

public Vector3 impactPoint { get; }

Property Value

Vector3

initialVelocity

World velocity of the water as it leaves the outlet, in metres per second.

public Vector3 initialVelocity { get; }

Property Value

Vector3

jet

How full the stream is: 0 there is none (the spout drips, or is dry), up to 1 a full jet. Never both a stream and drips.

public float jet { get; }

Property Value

float

localDirection

Direction the water leaves the outlet, in local space. Set values are normalised. Outside Play mode the editor traces the arc again after a change.

public Vector3 localDirection { get; set; }

Property Value

Vector3

pressure

How far the pressure behind the outlet has built up: 0 the water only dribbles off the lip, 1 it leaves at full speed along the traced arc.

public float pressure { get; }

Property Value

float

roofSize

Size of the roof draining into the spout, in metres (0 or more): bigger roofs lag further behind the rain.

public float roofSize { get; set; }

Property Value

float

speed

Speed the water leaves the outlet, in metres per second (0 or more). Outside Play mode the editor traces the arc again after a change.

public float speed { get; set; }

Property Value

float

width

Width of the outlet in metres (0 or more). 0 is a single point. Wider spouts sound lower and louder.

public float width { get; set; }

Property Value

float

worldDirection

World direction the water leaves the outlet, normalised.

public Vector3 worldDirection { get; }

Property Value

Vector3