// sets direction void Turret::lookAt(const float3 &pos, bool at_once) { //TODO: rounding float3 center = boundingBox().center(); float2 dir(pos.x - center.x, pos.z - center.z); float len = length(dir); if(len < constant::epsilon) return; dir = dir / len; m_target_angle = vectorToAngle(dir); if(at_once) setDirAngle(m_target_angle); }
//TODO: redundant initialization? Entity::Entity(const Sprite &sprite, const XMLNode &node) :m_sprite(sprite) { m_pos = node.attrib<float3>("pos"); resetAnimState(); setDirAngle(node.attrib<float>("angle", 0.0f)); }
void Entity::setDir(const float2 &vec) { setDirAngle(vectorToAngle(vec)); }
void Turret::nextFrame() { setDirAngle(blendAngles(dirAngle(), m_target_angle, constant::pi / 4.0f)); ThinkingEntity::nextFrame(); }