File:Documentation Index
Fetch the complete documentation index at: https://docs-unity.molca.id/llms.txt
Use this file to discover all available pages before exploring further.
Assets/_MolcaSDK/_VR/Scripts/Scenario/Scoring/ScoringConfig.cs
Aggregation layers
ScoringConfig instances are used at step, activity, and scenario levels:
See Step scoring auxiliary, Activity scoring, and Scenario scoring.
ScoringType reference
Enum values and behavior matchScoringConfig.CalculateScore(float timeTaken, float accuracy = 1f) in ScoringConfig.cs. After the switch, the result is multiplied by scoreMultiplier; if allowNegativeScore is false, the final score is clamped to ≥ 0.
IsTimeBased() is true only for TimeBonus, TimePenalty, and Countdown (drives StepScoringAuxiliary OnStepUpdate refresh).
ScoringType | Uses timeTaken | Uses accuracy | Primary serialized fields | CalculateScore (before multiplier & negative clamp) |
|---|---|---|---|---|
None | — | — | (none) | 0 |
PointValue | Ignored | Ignored | basePoints | basePoints |
Binary | Ignored | Yes (0–1) | correctPoints, incorrectPoints | correctPoints if accuracy >= 0.5, else incorrectPoints |
TimeBonus | Yes | Ignored | targetTimeSeconds, maxTimeSeconds, minPoints, maxPoints | If timeTaken <= targetTime → maxPoints. If timeTaken >= maxTime → minPoints. Between: linear lerp from maxPoints at targetTime down toward minPoints at maxTime. |
TimePenalty | Yes | Ignored | maxPoints, pointsPerSecond, minPoints | maxPoints - (timeTaken * pointsPerSecond), then max(score, minPoints) (floor) |
Countdown | Yes | Ignored | countdownDuration, pointsPerSecond | remaining * pointsPerSecond where remaining = max(0, countdownDuration - timeTaken) |
Accuracy | Ignored | Yes (0–1) | minPoints, maxPoints | Lerp(minPoints, maxPoints, Clamp01(accuracy)) |
Shared tuning (all types except None)
| Field | Role |
|---|---|
scoreMultiplier | Applied to the computed score after the switch. |
allowNegativeScore | If false, final score is max(0, score) after the multiplier. |
GetMaxPossibleScore() (UI caps & normalization)
ScoringType | Returns (before needing final clamp in callers) |
|---|---|
None | 0 |
PointValue | basePoints * scoreMultiplier |
Binary | Max(correctPoints, incorrectPoints) * scoreMultiplier |
TimeBonus, TimePenalty, Accuracy | maxPoints * scoreMultiplier |
Countdown | countdownDuration * pointsPerSecond * scoreMultiplier |
Implementation detail
Prefer callingCalculateScore / GetMaxPossibleScore on ScoringConfig rather than duplicating formulas in gameplay code. StepScoringAuxiliary sets accuracy for Binary / Accuracy via SetCorrect, SetIncorrect, SetAccuracy, SetAccuracyPercent before finalize — see Step scoring auxiliary.
When to use
EmbedScoringConfig (serialized class, not necessarily a standalone asset) wherever scoring is configured: StepScoringAuxiliary, ActivityScoring, ScenarioScoring. Choose None when the layer should not contribute numeric score but you still want a placeholder in the Inspector.
Troubleshooting
- Scores always zero — Type may be None; or time-based config has
maxPoints/ windows set so the formula yields 0 at currenttimeTaken/accuracy. - Binary feels inverted — Accuracy is 0–1: use
StepScoringAuxiliary.SetCorrect/SetIncorrect(orSetResult(bool)) soCalculateScoretreats correct as 0.5 and above and incorrect below 0.5. - Unexpected negatives — Enable
allowNegativeScoreor raiseminPoints/ adjust TimePenalty rate; final value is still multiplied byscoreMultiplier.
Related
- Recipe: Add scoring to VR activities — step-by-step guide for configuring scoring in VR training activities
Unity Editor
Embedded ScoringConfig on StepScoringAuxiliary or standalone asset if you use ScriptableObject variants.
