How to blow bubbles

That is, how to make a DS2 character blow bubbles. I needed Lara to look realistic underwater, so that meant bubbles when she breathed out. I knew that it could be done, as there was a "breath mist" effect for the cold regions of the game, and I just had to track it down and copy the logic.

That was easier siad than done. I looked at all the triggers at the entrances to the cold regions, and found nothing. I checked the whole of the world folder for "breath_mist" trying to find a link to the effect. Nothing!

Finally Sharkull at SiegeTheDay pointed out the "environEffect" parameter in Moods.gas. It turned out that this does not point to the effect directly, but its name (yes, only its name) is used by the step_emitter.skrit (found in the world\contentdb\components\emitters folder). The reason it is hooked up this way is that step_emitter is in the character template already and provides an easy link to the Actor Game Object. As soon as the "left_foot_down" event is fired by the movement animation, the skrit gets control to play a footstep sound, but it also takes the opportunity to attach a breathing effect if it is not already running. It determines which one from the name of the effect named in the mood. If none are required, it stops the current one.

Of course, I had not provided any footstep events in her swimming animations, so I had to go back and add them before she could breathe! Then I discovered that a dummy effect was required to provide its name for the step_emitter logic, and it got very upset if it did not exist.

The bubble effect itself took me some time to get right. At first, the bubbles loved her so much, they followed her everywhere. Not too realistic, so I found the SetTargetDependency function in some other effects and used that to release the bubbles from their obsession.

Cloning the efct_breath_mist code also showed me how to use the DetachSimulation function to stop further bubbles from being generated, while allowing the first ones to continue travelling upward.

Lara 3