evgenij.zherenkov Posted November 8, 2019 Share Posted November 8, 2019 Hello! I apply force to the PlayerActor so that it moves horizontally. Logically, it should be uniformly accelerated (using gravity as an example), but its speed will fluctuate from 1.2-2. It seems as if something is stopping him from accelerating. In the vertical plane, everything works correctly. I use addForce() in the flush() function. And if I’m doing exactly the same but applying force to the created figures in maps, then everything works correctly. This effect is only in PlayerActor. PlayerActorPtr actor = PlayerActor::cast(Game::get()->getPlayer()); if (actor) { BodyRigidPtr obj = BodyRigid::cast(actor->getBody()); if (obj) { obj->addForce(obj->getCenterOfMass(), Math::vec3(0, 9.81f*obj->getMass(), 0)); } } Link to comment
alexander Posted November 11, 2019 Share Posted November 11, 2019 Hi Evgenij, You can't manage BodyRigid of the PlayerActor from your side. It changes its velocity every frame in the PlayerActor's update. Look at the SDK -> Samples -> C++ API -> Logics -> ComponentSystem -> CSPlayerActor.h/cpp. This is very close to the original code of the PlayerActor. Best regards, Alexander Link to comment
evgenij.zherenkov Posted November 15, 2019 Author Share Posted November 15, 2019 Thank you. Reworked management following the example of CSPlayerActor.h / cpp. At the right time, I turn off the processing the movement and apply force. Link to comment
Recommended Posts