[Lance] Seeking the most effective way to extract information from a listener and transfer it to the game engine. Currently working on making the Spaceship follow my mouse movements. I have created a MouseControls.js file that listens for mouse movement and records both the X and Y coordinates of the cursor. In order to send this information to the game engine, I utilized the following code:
this.sendInput('mouseMove', {
cursorX: this.mouseControls.cursorPos.cursorX,
cursorY: this.mouseControls.cursorPos.cursorY
});
When attempting to read the second parameter in the processinput method within the game engine:
inputData.inputOptions.cursorY
I encountered an error stating "Cannot read property 'cursorY' of undefined." While other control keys function consistently every time, I am struggling to pass variable information (such as cursorX/Y) around effectively. These modifications are being made to the Spaaace tutorial. Should I consider creating a mouse object instead?
UPDATE: After delving deeper into the issue and gaining more insight, I believe I have pinpointed the root cause of my problem:
At the point when the game engine processes inputs, it only receives the input name without any additional information. This setup works well for key presses that trigger consistent actions each time. However, with mouse movement, upon receiving the "mouseMove" input, I also need to access the mouse's X and Y position from my Mouse Controller, which seems to be inaccessible from the game engine perspective. How can I retrieve these values at that specific moment?
Given that you cannot view my code directly, this situation is akin to extracting the "activeInput.up" value from KeyboardControls within the GameEngine's processinput method.