So, you’d first of all want to create two variables (in the default script of the frame) set to the selected characters. By default, let’s set the chosen characters are “none”
// default script, first frame
project.p1='none';
project.p2='none';
Next, select each character box and turn it into a clip.
Next, create a function for the select coins inside of the default script of the first frame.
This function will be used to detect which character each select coin is touching.
project.selectCoin=function(a){
var options=[rei,alex,sam,yellow,box,rod]; // array of all options
var r='none'; // default value is "none"
options.forEach(function(b){ // for every option...
if(a.hits(b)) // if touching coin
r=b.identifier; // change value to the name of the option
});
return r; // return the results
};
Since the coins are moved by keyboard, inside of the “keyreleased” script for SP1 coin, add this script:
project.p1=project.selectCoin(this);
Do the same for the SP1_copy clip, but switch “project.p1” with “project.p2”
This way, project.p1 and project.p2 will both be set based on which character box each selecting coin is touching (by “selecting coin” I mean SP1 and SP2, idk if selecting coins is their name but I’ll call them that for now).
Here’s an example file: _game4-6-2023_18-36-32.wick (2.0 MB)
I added in a text clip to show you what project.p1 and project.p2 variables are set to.