MusicSpinner¶
A component meant to be attached on any GameObject via Unity, it will get a RigidBody component on its own on Start.
This component is only used in the BugariaTheater
map to implement GameObjects spinning as a sound is played multiple times in succession with varying pitch and length as it is spinned using Beetle
's Horn Slash field ability. When it has spun enough, an item is launched from it if it wasn't obtained already.
While it's only used there, it has several configurations available. Here are the public fields:
notes
: The list of pitches and length of each times to play thesoundclip
during a full spinning cycle. Each x componets represents the timestamps the playback should happen in seconds and each y components represents the pitch to use for the playbackmaxtime
: The maximum playback time of all thenotes
in a full spinning cycle before restarting from the firstnotes
elementspinlimit
: The spin value requited (the value increases in increments ofspinhit
each Horn Slash) before the item spawns if it wasn't obtained alreadymaxspin
: The maximum spin value (the value increases in increments ofspinhit
each Horn Slash)spinstop
: An amount of frames that presents the value to decrease the spin value on each LateUpdate (the value increases in increments ofspinhit
each Horn Slash)spinhit
: The increment to increase the spin value of thespinner
on each Horn Slash (done on OnTriggerEnter with anyBeetleHorn
tagged colliders)musiclower
: The volume multiplier to use as the destination of a lerp applied tomusic[0]
.volume on each LateUpdate while the music is playing (the lerp is done from the existing volume with a factor of the spin /maxspin
where spin is clamped from 0.0 tomaxspin
so it approaches the scaled volume more as the cylinder spins more). This is mostly used to fade the current music using a value between 0.0 and 1.0flag
: A flag slot indicating if the item was obtained already (also bound to the NPCControl'sactivationflag
of the created item when launched ifitemtype
isn't 3 so not a Crystal Berry). Ifitemtype
is 3 (Crystal Berry), this value is a crystalbflags insteaditemtype
: The type of item launched from the cylinder:itemid
: The item, medal id or crystalbflags of the launched item. NOTE: Ifitemtype
is 3 (Crystal Berry), this value MUST match theflag
because they're both used differently, but represents the same thingitemtime
: The amount of time in frames to spawn the item before it disappears. If it's -1.0, the item won't disappearitempos
: The position to spawn the item before it is launchedbouncepos
: The direction to launch the item once it is spawnedspinner
: The list of GameObject to rotate using the spin value. All of them's isStatic will be set to false if they weren't when they spinrotation
: The axis of rotate of eachspinner
as they rotatesoundclip
: The base sound to use to play thenotes
musicvolume
: This field is UNUSED and it doesn't do anything.
On Start, the GameObject gets a Rigidbody component added without gravity in kinematic. Additionally, if the item hasn't been obtained yet and the Detector
medal is equipped, MainManager.map
.hiddenitem
is set to 100 which lets the beeper sound play.
All the spinning and item spawning logic happens in LateUpdate and the logic to detect Horn Slash to start the spin happens in OnTriggerEnter where the collider has the BeetleHorn
tag.