zhengwenxin Posted January 29, 2021 Posted January 29, 2021 Hi, I am using the engine of version 2.6. Now I have a problem of the player when I use the syncker plugin. I want to use the PlayerDummy type both of master and slave, so I change the game player to PlayerDummy type. Unigine::PlayerPtr player = Unigine::Game::get()->getPlayer(); if (player.get()) { std::string playerTypeName = player->getTypeName(); if (playerTypeName != "PlayerDummy") { Unigine::PlayerDummyPtr *playerDummy = new Unigine::PlayerDummyPtr; *playerDummy = Unigine::PlayerDummy::create(); Unigine::Game::get()->setPlayer((*playerDummy)->getPlayer()); Unigine::Log::message("come to set Player \n"); } } But when I do this ,the slave game player does not follow the master game player move when I move the master game player. If one of the game player is PlayerSpector between master and slave, the slave game player follow the master game player move. I hope somebody give me a help. Regards, Wenxin
alexander Posted February 1, 2021 Posted February 1, 2021 Hi zhengwenxin, As I understand it, you are using this code both on master and slave applications. In this case you create 2 different PlayerDummy that are not connected to each other. To connect them, use the method MasterInterface::createNode() on the master-side only. This method will create your object on the slave. For example: // on master only // get pointer to the master interface Unigine::Engine *engine = Unigine::Engine::get(); auto manager = (Unigine::Syncker::ManagerInterface *)engine->getPluginData(engine->findPlugin("Syncker")); auto master = manager->getMaster(); Unigine::PlayerPtr player = Unigine::Game::get()->getPlayer(); if (player.get()) { std::string playerTypeName = player->getTypeName(); if (playerTypeName != "PlayerDummy") { Unigine::PlayerDummyPtr *playerDummy = new Unigine::PlayerDummyPtr; *playerDummy = Unigine::PlayerDummy::create(); Unigine::Game::get()->setPlayer((*playerDummy)->getPlayer()); Unigine::Log::message("come to set Player \n"); master->createNode(*player_dummy); } } P.S. Anyway, the Syncker plugin synchronizes camera automatically if you don't use Game::setPlayer() on the slave side. If you create cameras on the master only it would works as expected. Best regards, Alexander
zhengwenxin Posted February 2, 2021 Author Posted February 2, 2021 Hi Alexander, Thank you very much for your help. It is because I want to use the player roll angle motion in the slave of Syncker plugin, so I change the player type to PlayerDummy. I test the way that you told me . The slave game player move follow the master game player,but when the master game player do roll motion,the slave is still. The slave game player does not follow master move when the master game player do roll motion. Does it have some way to make the slave do roll motion follow the master? Regards, Wenxin
alexander Posted February 2, 2021 Posted February 2, 2021 Hello, Does it have some way to make the slave do roll motion follow the master? Try to use setSlavePlayer() right after createNode(): // on master only // get pointer to the master interface Unigine::Engine *engine = Unigine::Engine::get(); auto manager = (Unigine::Syncker::ManagerInterface *)engine->getPluginData(engine->findPlugin("Syncker")); auto master = manager->getMaster(); Unigine::PlayerPtr player = Unigine::Game::get()->getPlayer(); if (player.get()) { std::string playerTypeName = player->getTypeName(); if (playerTypeName != "PlayerDummy") { Unigine::PlayerDummyPtr *playerDummy = new Unigine::PlayerDummyPtr; *playerDummy = Unigine::PlayerDummy::create(); Unigine::Game::get()->setPlayer((*playerDummy)->getPlayer()); Unigine::Log::message("come to set Player \n"); master->createNode(*player_dummy); master->setSlavePlayer(~0, *player_dummy); // change current camera in all slaves } } Best regards, Alexander
Recommended Posts