Race condition in coil activation

Open
#9 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
csharp, unity
Domain
game-dev

Research direction

Start by tracing Unity's Player.Start, CoilPlayer.OnStart, CoilPlayer.HandleCoilEvent, and IGameLogicEngine.OnCoilChanged, then reproduce the table script and "Pulse Coil" sequence. Done means the ball spawns reliably regardless of the order in which the relevant startup methods run.

Written by the indexing model from the issue text.

Description

Problem

This script has no effect:
image
This script causes the ball to spawn:
image

Cause

What should happen is:

  1. Player.Start is called by Unity
  2. CoilPlayer.OnStart is called
  3. CoilPlayer.HandleCoilEvent is added as a callback to IGameLogicEngine.OnCoilChanged
  4. The table script starts running and the "Pulse Coil" node is executed
  5. The ball spawns

The problem is that the table script starts running before Player.Start is called and nothing happens because CoilPlayer.HandleCoilEvent does not yet observe IGameLogicEngine.OnCoilChanged. This might be non-deterministic as well because the order of in which Start is called on MonoBehaviours is. Not sure how it is in Visual Scripting.

Dominant language
C#
Stars
0
Forks
1
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from VisualPinball/VisualPinball.Unity.VisualScripting

All issues in VisualPinball/VisualPinball.Unity.VisualScripting

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.