Repository navigation
feat: mobs play their own animations, sounds and particles while they are used - the smithy rings, sparks and steams - #578
Conversation
…ble outside AnimationSystem - no behaviour change - AnimationEffectPlayer (Adapters/Animations) plays a track instance's *eventSFX/*eventPFX/*eventPFXStop; AnimationSystem owns one (one-off particles, as before), mobs will own one that builds each effect once and replays it - AnimationSampling (Models/Animations, static, Burst) holds the frame interpolation and Nlerp of AnimationPoseJob - IVirtualObject.IsHingeMob(): the door/chest rule of the VR grab (MobInteractionService.ShouldHandleGrab) in one place Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…) - no behaviour change UseMob's last back transition, AI_StandUp(Quick) and AiHandler.ReEnableNpc cleared the mob, slot, state and body state each on their own. The mob's own animation will stop there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ads (MobAnimationService) - MobAnimationService (Services/Vobs): which mobs animate (an oCMobInter family member with an .MDS visual - no doors, chests, beds, fireplaces), the track names of a state change (T_S0_2_S1, S_S1, T_S1_2_S0) in the mob's own model script, one-shot logs for missing models/tracks (missing tracks Editor only) - At WorldSceneLoaded the world's mob models are baked and their sounds decoded (P3), with an Editor log of the tracks found per model - IMobAnimator / IMobAnimatorFactory: the port the MobAnimator adapter will implement - AnimationService.GetSkeleton also takes the hierarchy from an .MDL (hierarchy and mesh in one file), like the mesh builder Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…icles (MobAnimator) - nothing calls it yet - MobAnimator (Adapters/Vob, added on first use by MobAnimatorFactory): maps the model's nodes once, samples the rigid nodes on the CPU (AnimationSampling), plays a transition then the state's loop, events through its own AnimationEffectPlayer (one 3D sound, linear to the event's range; particles built once and replayed); Update only while something plays - users per mob (slots): the last one leaving lets a running transition end, plays the way back (T_S1_2_S0) and rests - safety net once per loop round: a user that is gone, culled, dead or no longer at the mob stops it - MobAnimationService: OnStateChanged / Stop / StartHeroUse / StopHeroUse / IsStillUsing; IMobAnimatorFactory bound in ReflexProjectInstaller Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e an NPC or the hero uses them - the smithy rings, sparks and steams - UseMob: every transition of the user also plays the mob's own (T_S0_2_S1 then S_S1, ...) - NpcService.ReleaseMob stops it; ReleaseMob now also runs at death (NpcDeathDomain.Die - a killed smith frees the anvil) and when a culled NPC is moved to its routine waypoint (AiHandler.DisableNpc, like ReEnableNpc: mob state -1) - the hero: levers/wheels swing into their new state (trigger branch 0 <-> 1); a mob with a dialog (anvil, grindstone, rune table) works while its dialog is open (new GlobalEventDispatcher.MobDialogEnded, raised where DialogService drops the mob dialog anchor); without a dialog (the forge's item swap) it works once, there and back - the safety net also stops for a knocked out user (IsDown) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bs' own animations (Docs/mobs.md, ADR) - Docs/mobs.md: MobState writers (UseMob, AiHandler, MobInteractionService, VRMobHinge, MobStatesSaveSection), NpcService.ReleaseMob as the one end of a usage, the animation classes and data flow, the light player, follow-ups, a "where does my change go" table - architecture.md: "Where does my code go?" row and principle 8 point to Docs/mobs.md - ADR 2026-11-25-mob-animations: why mobs animate, the hero's smithy, no doors/chests/beds, no forge light, no switch, the own light player (not AnimationSystem per mob) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y on import) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e fire no longer roars on after the smith walked away A lever pull without a user still lets its sound play out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t user's release resets the mob state in NpcService.ReleaseMob Wld_GetMobState then reads 0 and a save no longer keeps the anvil as used. Before, only a culled NPC reset it (AiHandler). An NPC only walking to the mob doesn't touch its state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ared (MobInteractionService) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…en when the world is left (MobAnimationService) A mob that isn't loaded yet gets no animator - the hero's lever pull then plays no animation, now with an Editor log. On a world change or a loaded game the hero's mob dialog use is cleared, so it never points at a destroyed mob. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Design and reviewDesign. Built with the
Author's decisions: all used mobs except doors, chests and beds; the hero's own forging animates the mob; no extra forge light; G1+G2, VR+Flat, no flag. Review of the build. Architecture: fits with concerns, plan followed. Gothic: no blocking bug. Fixed:
Kept on purpose: an NPC that is culled frees its mob at once. Follow-ups: #576. Editor check (G2 Khorinis):
|
… anvil, grindstone, quench and water pipe are no longer all at full volume - SfxModel caches each instance's C_SFX_DEF vol (0..127 as 0..1); a random variant (_A1, _A2) has its own - AudioService.GetRandomSoundClip(name, out volume): the picked sound's volume, 1 for a plain .wav name - AnimationEffectPlayer: a clip plays at it, a footstep one-shot gets it as volumeScale - an NPC's animation clips play on an own source next to NpcSound (_AnimationSfx, created on the first clip with NpcSound's settings): hits, weapon draws and steps play on NpcSound as one-shots and were turned down by the last clip's volume (and range) otherwise; a mob's source is its own already - VRMouth: eating, drinking and smoking at the VR mouth use it too (SMOKE_JOINT 20) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mob animation sounds follow it, a playing loop at once Gothic.ini [SOUND] soundVolume (MENU_OPT_AUDIO) was written by the menu but applied to nothing. - AudioService.SoundVolume: the option 0..1, read on first use and again when the menu changes it (logged, LogCat.Audio) - AudioService.SetSfxVolume(source, volume): Gothic's volume of the sound times the slider; the source is remembered and set again on the option change (no polling), destroyed ones are dropped on the next world - VOB sounds and day/night sounds (VobInitializerDomain), NPC and mob animation clips (AnimationEffectPlayer) use it; footsteps, eating/drinking/smoking at the VR mouth and Snd_Play sounds get it when they play - voices and music are untouched (music has its own slider) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… - it was hidden as unsupported Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…top end is a third louder for who wants more Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix: sound effects play at Gothic's own volume and the sound effects slider is back - the smithy is no longer deafening
There was a problem hiding this comment.
Claude: A lot of information is gone from this file. Where is it now?
There was a problem hiding this comment.
Claude: A lot of source code (maybe logic?) is now in an Adapter. Correct this way?
There was a problem hiding this comment.
Claude: Correct as an Adapter? Or better a Service/Domain?
There was a problem hiding this comment.
Claude: Correct as an Adapter? Or better a Service/Domain?
|
|
||
| // Gothic's own [SOUND] 0..1, the options' sound effects slider (AudioService.SoundVolume). | ||
| public const string SoundVolume = "soundVolume"; | ||
| public const float SoundVolumeDefaultValue = 0.75f; // Gothic's own volume (AudioService) |
There was a problem hiding this comment.
Claude: Why do we keep it separate? Gothic itself has it with 1f by default (please check ini). Why the separation here?
| { | ||
| source.maxDistance = soundData.Radius / 100f; // Gothic's values are in cm, Unity's in m. | ||
| source.volume = soundData.Volume / 100f; // Gothic's volume is 0...100, Unity's is 0...1. | ||
| // Gothic's volume is 0...100, Unity's is 0...1. Times the player's sound volume, a loop follows the slider. |
There was a problem hiding this comment.
Claude: Good fix. But I don't understand this information from comment: Times the player's sound volume, a loop follows the slider.
There was a problem hiding this comment.
Claude: Is this a performance bottleneck? When are these frame information read and stored? Loading time or runtime each time we need it?
There was a problem hiding this comment.
Claude: Is performance handled well in this implementation?
| yield return new WaitForSeconds(startDelay); | ||
| if (clip != null) | ||
| _mouthAudio.PlayOneShot(clip); | ||
| _mouthAudio.PlayOneShot(clip, volume * _audioService.SoundVolume); |
There was a problem hiding this comment.
Claude: Just a question. Is there no Unity internal feature to set the volume once and it is applied automatically? I mean: Currently we need to add volume to each sound manually. What if we forget it. 😢
…uses it is read from the NPCs' own mob state, no second user list MobAnimationService asks VobService.GetOtherMobUsers (+ IsUsingMob) and the hero's dialog mob to decide whether a user joins or the last one left. MobAnimator only plays tracks; its user list, the per-loop IsStillUsing safety net and the adapter's call back into the service are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… - the anvil stops and is free for others (NpcKnockoutDomain -> ReleaseMob) Like the engine's Npc::onNoHealth, which quits the interaction for death and unconsciousness. Before, only the removed per-loop safety net stopped the mob's animation, and the NPC kept the mob reserved while lying there. ReleaseMob's doc and Docs/mobs.md name the paths; world change/load and UseMob's dropped walk reservation need no release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d of staying silent (MobAnimator) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oup - every sound effect follows it, a voice doesn't All sound effect sources play through AudioMixer's SoundEffects group; Gothic.ini soundVolume sets its exposed SoundEffectsVolume (20*log10, 0 = -80 dB) at Gothic.ini load and when the menu changes it. A source's volume keeps only Gothic's own (C_SFX_DEF vol, a VOB's volume): the per-source registry (SetSfxVolume) and the "* SoundVolume" multiplications are gone, and so is its leak and the clamp at 1. - Prefabs (via UnityMCP): NPC sound (Core + VR oCNpc BIP01), VR door/chest lock picking, the player's mouth. - Runtime sources: AudioService.AddSfxSource (mob animator, burning NPC, barrier thunder, hero body/steps, spell invest loop) and AudioService.PlaySfxAtPoint instead of AudioSource.PlayClipAtPoint (particles, movers, bow, crossbow, torch, backpack, pickpocket, trade, spells, XriSfxPlayer). - NPC dialog voices get no mixer group instead of copying NpcSound's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… is Gothic's own volume of each sound Gothic.ini soundVolume missing = 1 (the engine's default and the menu slider's), 0 dB on the SoundEffects group. The 0.75 "own volume" position and the louder top end are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ce that sits in its prefab - no source built at runtime, a new NpcSound setting can't be forgotten (AnimationEffectPlayer) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…f the system culture (AnimationEffectPlayer) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…till playing on the source (a forge fire loop) and is logged once (AnimationEffectPlayer, AudioService) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s volume and range) is decided in AudioService, the adapter only plays it (AnimationEffectPlayer, AudioService.GetAnimationSfx) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o, not a private literal in AudioService (behaviour unchanged) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sModelScriptVisual) and one names a mob's states and their animations (MobStateNames), used by MobAnimationService and UseMob (behaviour unchanged) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… screen, frame by frame, and all of a mob's state tracks are baked, not only S0/S1 (MobAnimationService.WarmWorldMobsAsync, WorldScene, MobStateNames.IsOwnStateAnimation) Before, the warm-up ran synchronously in the WorldSceneLoaded listener (~115 ms in the Editor for G2 Khorinis, more on Quest 2) and only baked T_S0_2_S1, S_S1, T_S1_2_S0 - mobs reaching S2 or STAND<->S0 still baked on first use. Now WorldScene awaits it right after the VOBs; FrameSkipperService yields between tracks. Every state animation in the mob's model script (T_<state>_2_<state>, S_<state>) is baked and its sounds decoded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…1) and the hammering range The sound effects slider is Gothic's global volume: 1 plays each sound at its own Gothic loudness, lower values turn all sound effects down together. Voices and music are not part of it. Hammering reaches 24 m instead of Gothic's 10 m so Fellan's hammering is heard at Alwin's sheep pen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of the build and what was doneLocal review on
Answers to my inline comments
Checks
Still open
🤖 Generated with Claude Code |
…thic - the hammering override is gone (#569) Every animation sound now fades linearly to silence at its own Gothic R: range (cm -> m), as OpenGothic does with OpenAL linear distance, max distance = range. The per-sound override (HAMMER 24 m, Constants.Audio) is removed, so Fellan's hammering is heard up to 10 m again. Whether the original fades more gently is open in #569. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Mobs now play their own state animations, with their sounds and particles, while an NPC or the hero uses them, like in the engine. In Khorinis' smithy (G2):
FORGE_ANVIL,ANVIL_SPARKS);FORGE_SHARPEN,SHARPSTONE_SPARKS);FIRE_HOT,FORGE_FIRE);FORGE_WATER,WATERVAPOUR).Stoves, pans, barbecues, levers, wheels, the water pipe and the rune maker work the same way: every mob with an MDS that has
T_S0_2_S1/S_S1/T_S1_2_S0. On the G2 world that is 12 models, baked during the load in 115 ms (editor).The behaviour:
MobAnimatorturns itself off), and particle effects are built once per mob and replayed.Technical:
MobAnimationService(Services/Vobs) with theIMobAnimator/IMobAnimatorFactoryport, andMobAnimator(Adapters/Vob), a CPU player for a mob's few rigid nodes.AnimationEffectPlayer(SFX/PFX events) andAnimationSamplingare extracted fromAnimationSystem/AnimationPoseJob, shared by NPCs and mobs, with no behaviour change for NPCs.NpcService.ReleaseMobis now the one place an NPC lets go of a mob:AI_StandUp, death, culling, starting over. The last user's release resets the mob state, so a smith killed at the anvil leaves it free.IsHingeMobholds the rule now shared by the VR grab and this service.GlobalEventDispatcher.MobDialogEnded(the hero's mob dialog closed).Docs/mobs.md(who writes the mob state, saving, animations), plus a row in "Where does my code go?".Stacked on #574. The sound effect code moved into
AnimationEffectPlayer, which now calls #574'sAudioService.GetSfxRangeMeters. Merge #574 first.Why
Playtest (G2 Khorinis): the smithy was silent and still, with no sparks, a grindstone that didn't turn, and no forge sounds. The mobs' own MDS animations, which carry them, were never played.
How to test manually
[MobAnimation] <model>: T_S0_2_S1, T_S1_2_S0, S_S1per model andAnimations of N mob models baked in X ms.Save/load
Nothing new is saved: the mob state already is (
MobStatesSaveSection), and a mob's animation starts again with the next use after a load.Known gaps / follow-ups
Docs/adr/2026-11-25-mob-animations.md🤖 Generated with Claude Code