void EnemyTurret::TrackPlayerPos() { Mat3 transMat = m_node->getFinalTransform(); Vec2 playerPos = m_player->getNode()->getFinalTransform().GetTranslation(); Vec2 diff = Vec2( playerPos - Vec2(transMat.GetTranslation().x + (m_texture->getWidth() * transMat.GetScale().x / 2) + m_pivot.x, transMat.GetTranslation().y + (m_texture->getHeight() * transMat.GetScale().x / 2) + m_pivot.y)).GetNormalised(); //get the radian float rot = Vec2(0,1).GetAngleBetween(diff); //get the parent tanks rotation and offset the turrets rotation float allRot = transMat.GetUpRot(); float thisRot = m_node->getNodeTransform().GetUpRot(); float rotOffset = allRot - thisRot; //set rotation to point at mouse and offset the parents rotation m_node->manipMat3()->SetRotation(rot - rotOffset); }