Topic: Collision and camera in plugins question?
Hi, im making a plugin in c++ and want entity to colide with level mesh and stop moving when it collided. What functions i should use? I'm using isObjectInCollision, but it doesnt behave as i expected(just rotates with mouse movement). Actually i cant find description for this function, so i'm not sure what it does. How to find that collision occured? Please help. Currently i have:
void Player::move(MObject3d * parent,MScene * scene,MEngine * engine,float speed)
{
MVector3 pos=parent->getTransformedPosition();
MVector3 rot=parent->getTransformedRotation();
MOEntity* ent= scene->getEntityByName("Player");
MPhysicsContext * physCont = engine->getPhysicsContext();
MPhysicsProperties * phyProps = ent->getPhysicsProperties();
pos.x += sin(rot.y)*speed;
pos.y += cos(rot.y)*speed;
pos.z += sin(rot.y)*speed;
if (physCont->isObjectInCollision(phyProps->getCollisionObjectId())>0)
{
parent->setPosition(pos);
}
}
Last edited by Skywriter (2013-09-19 16:50:01)