void Location::setOrientationFromVelocity(const Vector3& velocity) { // If we haven't got any velocity, then we can do nothing. if (velocity.squareMagnitude() > 0) { orientation = real_atan2(velocity.x, velocity.z); } }
void Wander::getSteering(SteeringOutput* output) { // Make sure we have a target if (target->squareMagnitude() == 0) { internal_target = character->position; internal_target.x += volatility; } Vector3 offset = *target - character->position; real angle; if (offset.x*offset.x + offset.z*offset.z > 0) { // Work out the angle to the target from the character angle = real_atan2(offset.z, offset.x); } else { // We're on top of the target, move it away a little. angle = 0; } // Move the target to the boundary of the volatility circle. internal_target = character->position; internal_target.x += volatility * real_cos(angle); internal_target.z += volatility * real_sin(angle); // Add the turn to the target internal_target.x += randomBinomial(turnSpeed); internal_target.z += randomBinomial(turnSpeed); Seek::getSteering(output); }
void Kinematic::setOrientationFromVelocity() { // If we haven't got any velocity, then we can do nothing. if (velocity.squareMagnitude() > 0) { orientation = real_atan2(velocity.x, velocity.z); } }