Make betrothals and pregnancies
Goal: a promise to marry now, a wedding later, and a child some time after the wedding.
What is built in, and what is not
Section titled “What is built in, and what is not”The package does not know the word betrothal or pregnancy. There is no engaged state and no pregnancy state. The README says it plainly: a betrothal is a relationship variable, a Wait Until and a Marry node, and a pregnancy is a Wait before Create Actor, or your own timer before actor.HaveChild.
| You want | The package gives you | You build |
|---|---|---|
| A wedding | Marry node, actor.Marry(spouse) |
The reason it happens now |
| A promise before it | Nothing | A variable or a tie, and a wait |
| A birth | Create Actor with Create set to A child of, actor.HaveChild(...) |
The delay and the odds |
Betrothal in a scheme
Section titled “Betrothal in a scheme”- Add a variable that records the promise. Set its Belongs To to Each Relationship, so each actor can hold a value toward each other actor (see Variables). A tie works too: the demo scheme Pledge the Young uses an Add Tie node with
Promised, a tie kind of the demo’s own database; make your own on Behaviour ▸ Opinions. - After the promise, add a Wait Until. Its list of conditions is the moment of the wedding, for example both partners at least 16, as the demo does.
- Add a Check Marriage node with Check set to Can marry, and the partner in Other Actor. Then Marry with Actor and Spouse.
- Wire Married to what happens next, and Refused to undoing the promise.
You will see: the scheme waits at Wait Until, and the wedding runs when its conditions are met. Marry continues through Married, or through Refused when a rule forbids it.
Pregnancy in a scheme
Section titled “Pregnancy in a scheme”- Add a Wait. The Unit can be Days, Months or Years, and Random Length gives a range.
- Add Create Actor. Set Create to A child of, pick the Parent, and turn on Second Parent for the other parent.
- Use Store In to keep the child for later nodes.
The same in code
Section titled “The same in code”Example. Compiled against the package’s runtime assembly; not run in Unity. Both calls are in Actor.Family.cs; Marry and HaveChild return null when refused.
if (woman.CanMarry(man)) woman.Marry(man);var child = woman.HaveChild(man);IM.onChildBorn fires after a birth. See Families in code.
What can go wrong
Section titled “What can go wrong”- Marry or
Marry(...)is refused: a world rule orFamilyLaw.CanMarrysaid no. AskCanMarry(spouse, out var check)and readcheck.Text. - The child never appears: the wait did not end, or
HaveChildreturnednull. The reason is logged at Log level. - One partner dies or marries someone else while you wait: the demo’s Wait Until also ends when a child is dead or already married, so add those conditions to yours.