andrew.douglas Posted November 17, 2018 Share Posted November 17, 2018 Hi, While Editor is running and application logic is on, I would like to handle input from keyboard. Currently I am using a "Usage Example\Basic Object Movements" example from documentation int init() { engine.visualizer.setEnabled(1); Player player = new PlayerSpectator(); player.setPosition(Vec3(0.0f,-3.401f,1.5f)); player.setDirection(Vec3(0.0f,1.0f,-0.4f)); engine.game.setPlayer(player); int index = engine.editor.findNode("Player"); if (index != -1) { sphere = engine.editor.getNode(index); } engine.controls.setStateKey(CONTROLS_STATE_AUX_0, 'p'); return 1; } // start of the main loop int update() { if (sphere != NULL) { float ifps = engine.game.getIFps(); float angle = ifps * 90.0f; // get the current world transform matrix of the mesh Mat4 worldTransform = sphere.getWorldTransform(); // get the direction vector Vec3 direction = Vec3(worldTransform.col1); engine.visualizer.renderDirection(sphere.getWorldPosition(), vec3(direction), vec4(1.0f, 0.0f, 0.0f, 1.0f), 0.1f, 0); if (engine.controls.getState(CONTROLS_STATE_AUX_0)) { Vec3 delta_movement = direction * movement_speed * ifps; sphere.setWorldPosition(sphere.getWorldPosition() + delta_movement); } mat4 transform = sphere.getTransform() * rotateZ(angle); sphere.setTransform(transform); } return 1; } but input is ignored when I am running a project in Editor. If I run the project from the DSK browser it works as expected. How can I handle the same input while the editor is executing application logic. Otherwise I have to keep running the project which is not the best experience while developing? Thanks, Andrew Link to comment
morbid Posted November 19, 2018 Share Posted November 19, 2018 Hi Andrew, that should work. Have you tried switching to the Engine Viewport and clicking inside the viewport? This will shift the focus from the editor and your input should work as expected. Thank you. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
andrew.douglas Posted November 20, 2018 Author Share Posted November 20, 2018 Hi Morbid, Thank you, I'll try that when I get home. I think I would have tried that in the first place, but there is a small chance that I didn't :) Cheers Link to comment
Recommended Posts