Trying to find the modulo problem
This commit is contained in:
@ -44,7 +44,8 @@ namespace Dawn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline float_t randRange(float_t min, float_t max) {
|
static inline float_t randRange(float_t min, float_t max) {
|
||||||
return mathMod(randomGenerate<float_t>(), (max - min)) + min;
|
float_t n = randomGenerate<float_t>();
|
||||||
|
return mathMod(n, (max - min)) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline glm::vec2 randRange(glm::vec2 min, glm::vec2 max) {
|
static inline glm::vec2 randRange(glm::vec2 min, glm::vec2 max) {
|
||||||
|
@ -25,9 +25,11 @@ void EntityAIWalk::onStart() {
|
|||||||
case ENTITY_AI_WALK_MODE_FOLLOW_TARGET:
|
case ENTITY_AI_WALK_MODE_FOLLOW_TARGET:
|
||||||
this->updateFollowTarget(delta);
|
this->updateFollowTarget(delta);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENTITY_AI_WALK_MODE_WANDER:
|
case ENTITY_AI_WALK_MODE_WANDER:
|
||||||
this->updateWander(delta);
|
this->updateWander(delta);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENTITY_AI_WALK_MODE_STAY:
|
case ENTITY_AI_WALK_MODE_STAY:
|
||||||
this->entityMove->direction = glm::vec2(0, 0);
|
this->entityMove->direction = glm::vec2(0, 0);
|
||||||
break;
|
break;
|
||||||
@ -48,8 +50,9 @@ void EntityAIWalk::updateWander(float_t delta) {
|
|||||||
wanderTimeToNextDecision = randRange(wanderTimeRandomRange.x, wanderTimeRandomRange.y);
|
wanderTimeToNextDecision = randRange(wanderTimeRandomRange.x, wanderTimeRandomRange.y);
|
||||||
|
|
||||||
// Do we want to move?
|
// Do we want to move?
|
||||||
if(randRange(0.0f, 1.0f) < wanderDoNotMoveChance) {
|
float_t rr = randRange(0.0f, 3.0f);
|
||||||
this->entityMove->direction = glm::vec2(0, 0);
|
if(rr < wanderDoNotMoveChance) {
|
||||||
|
wanderDestination = physics3Dto2D(transform->getLocalPosition());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,8 @@ namespace Dawn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline float_t mathMod(float_t value, float_t modulo) {
|
static inline float_t mathMod(float_t value, float_t modulo) {
|
||||||
return (float_t)fmod(value, modulo);
|
float_t n = fmod(value, modulo);
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user