I have some code for controlling a character with was, very standard using the actionManager onKey down event.
I was struggling for a long time with finding out why the action manager would only detect key presses after I had clicked off the canvas and then back on or changing window and then coming back. I checked with console.log and the actual action just wasn’t firing.
Eventually, I found one line in my code that was to blame:
I had this line near the end just before creating the action manager and it when removed it seems everything works. This is however the exact opposite of what I would have expected. I’ll also note that the position of this line doesn’t seem to make any difference (before or after the action manager or anywhere else), if I run scene.attachControl() anywhere it has the same effect of blocking the action manager from firing until going off the page and back again.
I suppose this is mostly a question about understanding what the intended use of this function is because the code seems to work now, but an explanation would be very much appreciated if any knows what was going on here.