burakdogancay Posted January 16, 2020 Share Posted January 16, 2020 (edited) Hello everyone, Nowadays i am working on the simulation system that consist of several objects and their object movement orientation.I try to move one object to target and track it with specified changes in x and y axis.But unfortunately the object aproaches to target without of smooth movement.It directly jumps one point to another one with big numbers. What i want it to move to target with smooth movement in y and x axis. For example : void missiletargettracking2() { if((unigineNodes.mObject->getWorldPosition().x<uparameters.mmissilehtstargetpoint.x+1.2)&&(unigineNodes.mMissileKornetLeft->getWorldPosition().y<uparameters.mmissilehtstargetpoint.y + 1.2)){ unigineNodes.mObject->setWorldPosition(unigineNodes.mObject->getWorldPosition()+Unigine::Math::Vec3(0.1,0.1,0)*parameters.mMissileTrackingSpeed*Unigine::Game::get()->getIFps()); } else if((unigineNodes.mObject->getWorldPosition().x<uparameters.mmissilehtstargetpoint.x +1.2)&&(unigineNodes.mObject->getWorldPosition().y>uparameters.mmissilehtstargetpoint.y + 1.2)){ unigineNodes.mObject->setWorldPosition(unigineNodes.mObject->getWorldPosition()+Unigine::Math::Vec3(0.1,-0.1,0)*parameters.mMissileTrackingSpeed*Unigine::Game::get()->getIFps()); } else if((unigineNodes.mObject->getWorldPosition().x>uparameters.mmissilehtstargetpoint.x -1.2)&&(unigineNodes.mObject->getWorldPosition().y<uparameters.mmissilehtstargetpoint.y - 1.2)){ unigineNodes.mObject->setWorldPosition(unigineNodes.mObject->getWorldPosition()+Unigine::Math::Vec3(-0.1,0.1,0)*parameters.mMissileTrackingSpeed*Unigine::Game::get()->getIFps()); } else if((unigineNodes.mObject->getWorldPosition().x>uparameters.mmissilehtstargetpoint.x- 1.2)&&(unigineNodes.mObject->getWorldPosition().y>uparameters.mmissilehtstargetpoint.y - 1.2)){ unigineNodes.mObject->setWorldPosition(unigineNodes.mObject->getWorldPosition()+Unigine::Math::Vec3(-0.1,-0.1,0)*parameters.mMissileTrackingSpeed*Unigine::Game::get()->getIFps()); } qDebug() << "Object position "<< unigineNodes.mObject->getWorldPosition().x<<unigineNodes.mObject->getWorldPosition().y<<unigineNodes.mObject->getWorldPosition().z; } According to above code, object tracks the target in x and y axis but it directly increases "2" in x , y axis and moves through hard transitions. output: object position 1489 -521.729 40.749 object position 1490.59 -523.313 40.6973 object position 1492.17 -521.747 40.6479 object position 1493.62 -523.22 40.6106 object position 1495.18 -521.704 40.5835 object position 1496.66 -523.221 40.5736 object position 1498.25 -521.678 40.5813 How can i move it fast and apply smooth transition ? Thank you in advance Edited January 16, 2020 by burakdogancay Link to comment
cash-metall Posted January 16, 2020 Share Posted January 16, 2020 Hi! Can you describe your task in more detail? In you realization node will approach to the target infinite and along a strange trajectory... What kind of behavior do you expect? Should the node move directly to the target? what is the value of parameters.mMissileTrackingSpeed? how often is the missiletargettracking2 method called? in each update? Link to comment
burakdogancay Posted January 16, 2020 Author Share Posted January 16, 2020 1 ) parameters.mMissileTrackingSpeed = 230; 2) Yes, missiletargettracking2 method called in each update We know that this strange behaviour occurs cause of our method(missiletargettracking2) .We had no choice without of this implementation(we tried all other methodes but unfortunately they didn't work either).Because i really don't know how to move and rotate object in specified and correct trajectory for target. I had to use above method and it worked but this object moves like a jumping point to point.It does not provide smooth transition. Is there any way to draw a path to target and move object according to this path.Otherwise i have to use above method. Link to comment
cash-metall Posted January 17, 2020 Share Posted January 17, 2020 you use Quote unigineNodes.mObject->getWorldPosition()+Unigine::Math::Vec3(0.1,0.1,0)*parameters.mMissileTrackingSpeed*Unigine::Game::get()->getIFps() game->getIFPS in averrage ~0.14 (for 60 fps) this is newposition = current_position + 0.1 * 230 * 0.14 = current_position + 3.22 i.e, the position changes in each frame by 2 units - this is normal for such a high speed. it should look smooth. maybe you attach a video where you can see the "not smooth" movement? Link to comment
cash-metall Posted January 17, 2020 Share Posted January 17, 2020 I checked your code. in my opinion the object moves quite smoothly. isn't it? 6025-how-to-apply-smooth-transition-to-movement-of-the-object.mp4 2 Link to comment
burakdogancay Posted January 17, 2020 Author Share Posted January 17, 2020 (edited) But it moves slowly(I need faster movement), it jumps to the point to point with bigger steps when i increased speed which is parameters.mMissileTrackingSpeed = 230 or steps which is Unigine::Math::Vec3(0.1,0.1,0) . So the transition won't be shown like smooth.You will see when you applied bigger number on tracking speed or steps. Also our fps is close to "40" according to our landscape and environment, but yours is "290" Edited January 17, 2020 by burakdogancay Link to comment
Recommended Posts