simakov.artem Posted June 27, 2019 Share Posted June 27, 2019 Hi all! We want to check if the left mouse button was pressed once and so we use App::get()->clearMouseButtonState(App::BUTTON_LEFT) but then left mouse button is refused to work. It's a bug or we do smth wrong? Unigine version 2.7.2.1. Link to comment
silent Posted June 27, 2019 Share Posted June 27, 2019 Hi Artem, Could you please provide a sample code that you are using? Also engine startup options and defines (if any) will be interesting to see. Thanks! 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
simakov.artem Posted June 27, 2019 Author Share Posted June 27, 2019 1 hour ago, silent said: Hi Artem, Could you please provide a sample code that you are using? Also engine startup options and defines (if any) will be interesting to see. Thanks! silent, I have test this on default new project without plugins (after all attempt to force to work in main project). Just I have added Unigine::App::get()->clearMouseButtonState(Unigine::App::BUTTON_LEFT) into AppWorldLogic::update(). Link to comment
andrey-kozlov Posted June 28, 2019 Share Posted June 28, 2019 Hello Artem, That's the common pattern of using that function: if (Unigine::App::get()->getMouseButtonState(Unigine::App::BUTTON_LEFT)) { Unigine::Log::message("pressed\n"); Unigine::App::get()->clearMouseButtonState(Unigine::App::BUTTON_LEFT); } clearMouseButtonState is used here to log a message for every mouse button press instead of every frame when mouse button is pressed. Could you please elaborate what behaviour did you expect? Link to comment
simakov.artem Posted July 2, 2019 Author Share Posted July 2, 2019 andrey-kozlov, if I use your example into project (even empty) GUI (buttons, tabs, etc.) doesn't work. I think it's not normal behaviour. Link to comment
andrey-kozlov Posted July 2, 2019 Share Posted July 2, 2019 That's because GUI listening mouse buttons too. You could use Controls which is used for game logic exclusively. Unigine::ControlsPtr controls = Unigine::Game::get()->getPlayer()->getControls(); if (controls->getState(Unigine::Controls::STATE_FIRE)) { Unigine::Log::message("pressed\n"); controls->clearState(Unigine::Controls::STATE_FIRE); } Also we currently working on new input system which allows to handle keypress once in a more friendly way. Link to comment
Recommended Posts