Sportscode Building Blocks: Script a Passing Matrix in Minutes

Learn how to build a code win­dow to cap­ture pass­ing data and review performance.

Sportscode Building Blocks: Script a Passing Matrix in Minutes

Learn how to build a code win­dow to cap­ture pass­ing data and review performance.

Note: The fea­tures out­lined in this arti­cle are not avail­able with Sportscode Gamebreaker Plus. Contact us if you’re inter­est­ed in upgrad­ing to Sportscode Pro or Elite, to take advan­tage of this type of analysis.

Sportscode’s pow­er­ful script­ing lan­guage allows users to col­lect data and gen­er­ate com­pelling visu­al reports linked to video. Creating reports is a com­mon work­flow for many suc­cess­ful users who have cho­sen to take advan­tage of Sportscode’s abil­i­ty to dis­play cal­cu­la­tions from user-gen­er­at­ed data.

A ques­tion we often get is how to track pass­ing and receiv­ing of the ball using Sportscode. Regardless of the sport, this data is use­ful in track­ing play­er per­for­mance. In this blog we’ll show how just a few but­tons in a code win­dow can build an effec­tive pass­ing matrix.

Understand the Label Button Functionality

Label but­tons are cru­cial in this set­up, espe­cial­ly con­cern­ing the deci­sion of when to apply infor­ma­tion to code buttons.

  • Create two code but­tons and one label button.
  • Connect a code but­ton to a label but­ton with an acti­va­tion link.
  • Apply the but­ton before deactivations.

This means that the label but­ton infor­ma­tion will be pushed” before the active state of the cur­rent code but­ton. In oth­er words, the infor­ma­tion will be added to the last entered instance and not the cur­rent active code but­ton. Feel free to try the dif­fer­ences. You will see the result in your timeline.

Where Does the Ball Go?

With two code but­tons and one label but­ton it is already pos­si­ble to see who plays the ball. In this exam­ple we added a group name TO” as well.

  • Expand this set­up by adding more code but­tons for play­ers and cre­ate one cor­re­spond­ing label but­ton for each player’s code but­ton, attached by an acti­va­tion link.
  • Give the label but­ton the same name as the code but­ton, or use scripts to auto­mat­i­cal­ly take the name of the cor­re­spond­ing code but­ton name. In this case, Player 1 acti­vates a label. Because it is set to apply before deac­ti­va­tion, the label infor­ma­tion will be added to the instance pri­or to Player 1.

Where Does the Ball Come From?

Knowing where the ball came from is a lit­tle extra work. It requires more knowl­edge of the basics of script­ing. Once again, a label but­ton is the key ele­ment. Make sure each player’s code but­tons have a but­ton ID. This way, you’re able to change any but­tons name in the future and it won’t affect the script­ing. Using lead time or lag time is all up to you.

Add these four key scripts to your label but­ton and you’ll be ready to start cod­ing. Create the label but­ton (in green). Within the label but­ton we can spec­i­fy a cou­ple of actions.

  • $name1 = BUTTON NAME player1”

This script ref­er­ences the but­ton with ID player1”.

  • if (but­ton #’player1’ state = 1, RENAME $name1)

When the code but­ton with ID player1” is active, rename this label but­ton and give it the exact same name. This way you know which code but­ton with a player’s name was pressed for the last time.

  • if (but­ton #’player1’ state = 1, RENAME GROUP FROM”)

Change the group name as well. It makes it eas­i­er to orga­nize your labels and to read them in the matrix.

  • $start = COUNT INSTANCES WHERE ROW = START” etc.

This is an option­al lit­tle trick. Before you start the game you’ll want your key ele­ment label but­ton to be emp­ty. You’re ask­ing the script to check for a sub­ject, in this case with the name START”. If no instance is found with­in the time­line, rename your label to either noth­ing (“”), or in this exam­ple, START”. It gives you an extra as well — the START” label will be added to to the first play­er that has the ball. Remember to always press START” (grey) at the begin­ning of the game and again after you fin­ish the first half or quarter.

Checking the Result

After repeat­ing the script­ing process above for each play­er, you will imme­di­ate­ly see the result in your time­line. The label infor­ma­tion is vis­i­ble with­in the instance. In this case, you see an instance in the row of Player 2. And from whom did he get the ball? Exactly: FROM > PLAYER 1

Combining Both FROM and TO Ideas

Here’s an exam­ple code win­dow with a cou­ple of play­ers and one code but­ton for the oppo­nent. The top row con­tains the label but­tons — you know this because the iden­ti­fiers are shown. Second is the row with your play­ers’ code but­tons and at the bot­tom are the key ele­ment label but­ton con­tain­ing some scripts. Adding the oppo­nent but­ton enables you to track which play­er lost or won the ball most.

Three Data Points in One

And now for the fun part! For every instance in your time­line, you now know where the ball came from and where it goes. This way you’re able to check who was involved in any spe­cif­ic player’s action. With just one instance, we know three pieces of infor­ma­tion at any time while review­ing the video:

  • Who passed the ball
  • Who has the ball at this spe­cif­ic moment
  • Who will get the ball next

Review Results in the Matrix

Open the matrix and play around with swap­ping axes. If you upload this time­line to Hudl, you can share this analy­sis with the rest of your staff and your players.

Be Creative

Last but not least, we encour­age all our users to be cre­ative with Sportscode. After you gath­ered data like this, you could cre­ate cus­tom reports, heat maps or gath­er these sta­tis­tics in a sta­tis­ti­cal win­dow to use it in com­bi­na­tion with third-par­ty tools.

Click below to down­load the code win­dow used in this example.