change aim calculation

pull/593/head
Max 4 years ago
parent 52eccf1a2d
commit e56efdd562

@ -3867,11 +3867,14 @@ namespace MWWorld
return false;
}
osg::Vec3f World::aimToTarget(const ConstPtr &actor, const MWWorld::ConstPtr& target)
osg::Vec3f World::aimToTarget(const ConstPtr &actor, const ConstPtr &target)
{
osg::Vec3f weaponPos = actor.getRefData().getPosition().asVec3();
weaponPos.z() += mPhysics->getHalfExtents(actor).z();
osg::Vec3f targetPos = mPhysics->getCollisionObjectPosition(target);
osg::Vec3f weaponHalfExtents = mPhysics->getHalfExtents(actor);
osg::Vec3f targetPos = target.getRefData().getPosition().asVec3();
osg::Vec3f targetHalfExtents = mPhysics->getHalfExtents(target);
weaponPos.z() += weaponHalfExtents.z() * 2 * 0.75; // projectilemanager.cpp spawns bolts at 0.75 actor height
targetPos.z() += targetHalfExtents.z();
return (targetPos - weaponPos);
}

Loading…
Cancel
Save