As in this case player
is a reference to an array of objects, not to a specific sprite object.
See getAllInstances()
on: construct.net/en/make-games/manuals/construct-3/scripting/scripting-reference/object-interfaces/iobjectclass
Return an array of all instances of this object class.
You need to find your given sprite object in the array. If you have only one player, then player.getFirstInstance()
should do it. You also need to do the same to find the given ground object in your ground array.
One way to look for a specific object in an array can be seen in this post:
construct.net/en/forum/construct-3/scripting-51/handle-clicks-object-js-154194
In that example, in the function the // loops through all sprites
for loop is used to get a reference to each sprite in the array.
If you - for example - have an instance variable named myID
added to the sprite in the Editor, then in the JS for loop you can get its value like this:
const myID = sprites[i].instVars.myID;
console.log(myID);