dark99 Posted March 21 Share Posted March 21 Hi? When I call Input::setMouseGrab(true) by code, at least one left mouse click is need to control player's view How can I apply mouse grab mode without mouse click by code? Test code is here ------------------------------- if (Input::isKeyUp(Input::KEY_TAB)) { this->isPlayMode = !this->isPlayMode; if (this->isPlayMode) { Input::setMouseHandle(Input::MOUSE_HANDLE_GRAB); Input::setMouseGrab(true); this->playerActorPtr->setControlled(true); } else { Input::setMouseHandle(Input::MOUSE_HANDLE_USER); this->playerActorPtr->setControlled(false); } } Link to comment
silent Posted March 25 Share Posted March 25 You can try this approach: int AppWorldLogic::init() { // set our own mouse grab logic and engine is no longer responsible for this Input::setMouseHandle(Input::MOUSE_HANDLE_USER); return 1; } int AppWorldLogic::update() { if (Input::isKeyDown(Input::KEY_TAB)) { is_play_mode = !is_play_mode; if (is_play_mode) { // prevent cursor from going outside window Input::setMouseGrab(true); // enable camera control ControlsApp::setEnabled(true); ControlsApp::setMouseEnabled(true); } else { // just do the opposite settings... Input::setMouseGrab(false); ControlsApp::setEnabled(false); ControlsApp::setMouseEnabled(false); } } return 1; } For GUI clicks you can use following methods to control the mouse behavior: setMouseGrab: https://developer.unigine.com/en/docs/future/api/library/gui/class.gui?rlang=cpp&autotranslate=en#setMouseEnabled_int_void setMouseEnabled: https://developer.unigine.com/en/docs/future/api/library/gui/class.gui?rlang=cpp&autotranslate=en#setMouseEnabled_int_void Thanks! 1 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
Recommended Posts