Code: Select all
void level::playerIneraction(myEventReceiver r, IKinematicCharacterController *character, irr::scene::ICameraSceneNode *camera){
for(irr::core::list<IRigidBody *>::Iterator Iterator = objects.begin(); Iterator != objects.end(); Iterator++){
IRigidBody *object = *Iterator;
object->setGravity(irr::core::vector3df(0,-10,0));
irr::core::vector3df pos = object->getWorldTransform().getTranslation();
irr::core::vector3df posChar = character->getWorldTransform().getTranslation();
irr::core::vector3df rotChar = object->getWorldTransform().getRotationDegrees();
irr::f32 length = posChar.getDistanceFrom(pos);
if(r.isKeyDown(irr::KEY_KEY_E)){
if(length <= 40.f){
std::cout<<"can pick up"<<std::endl;
object->setGravity(irr::core::vector3df(0));
irr::core::matrix4 mat;
mat.setTranslation(irr::core::vector3df(posChar.X + 30,posChar.Y,posChar.Z));
object->setWorldTransform(mat);
}
else if(length >= 40.f){
std::cout<<"can't pick up"<<std::endl;
}
}
}
}