Code: Select all
objects.set_used(id + 1);
...
objects[id] = newNode;
...
objects[command.objectId]->setPosition(command.newPosition);
Code: Select all
objects.set_used(id + 1);
...
objects[id] = newNode;
...
objects[command.objectId]->setPosition(command.newPosition);
rogerborg wrote:That looks like you have an object with an ID of 0. I assumed from the sample file - and lack of requirements - that your objects were 1 indexed. If they're 0 indexed, then you could change the indexing in the code, e.g.:
Code: Select all
objects.set_used(id + 1); ... objects[id] = newNode; ... objects[command.objectId]->setPosition(command.newPosition);
bro.. i completed that. thnx for ur help. i modified it little. to make it sure it moves within 50 milliseconds.rogerborg wrote:That looks like you have an object with an ID of 0. I assumed from the sample file - and lack of requirements - that your objects were 1 indexed. If they're 0 indexed, then you could change the indexing in the code, e.g.:
Code: Select all
objects.set_used(id + 1); ... objects[id] = newNode; ... objects[command.objectId]->setPosition(command.newPosition);
Code: Select all
if(elapsedTime >= command.atTime)
{
diff = objects[command.objectId]->getPosition();
//objects[command.objectId - 1]->setPosition(command.newPosition);
//diff = objects[command.objectId - 1]->getPosition();
resultDegrees = change_orientation(diff, command.newPosition);
objects[command.objectId]->setRotation(resultDegrees);
anim_node = smgr->createFlyStraightAnimator(diff, command.newPosition, 50, false);
objects[command.objectId]->addAnimator(anim_node);
diff = objects[command.objectId]->getPosition();
commands.erase(eraseMe);
}