SimpleAI
 All Classes Namespaces Files Functions Variables Typedefs Macros Groups Pages
Wander.h
Go to the documentation of this file.
1 
4 #pragma once
5 
6 #include "Steering.h"
7 #include "common/Random.h"
8 
9 namespace ai {
10 namespace movement {
11 
18 class Wander: public ISteering {
19 protected:
20  const float _rotation;
21 public:
22  STEERING_FACTORY(Wander)
23 
24  explicit Wander(const std::string& parameter) :
25  ISteering(), _rotation(parameter.empty() ? ai::toRadians(10.0f) : Str::strToFloat(parameter)) {
26  }
27 
28  MoveVector execute (const AIPtr& ai, float speed) const override {
29  const float orientation = ai->getCharacter()->getOrientation();
30  const glm::vec3& v = fromRadians(orientation);
31  const MoveVector d(v * speed, ai::randomBinomial() * _rotation);
32  return d;
33  }
34 };
35 
36 }
37 }
Definition: MoveVector.h:10
Moves forward in the direction the character is currently facing into.
Definition: Wander.h:18
Defines some basic movement algorithms like Wandering, Seeking and Fleeing.
Steering interface.
Definition: Steering.h:47
MoveVector execute(const AIPtr &ai, float speed) const override
Calculates the MoveVector.
Definition: Wander.h:28