animator fix

This commit is contained in:
HENRY Benjamin
2021-06-07 12:02:01 +02:00
57 changed files with 944 additions and 382 deletions
+4 -2
View File
@@ -31,11 +31,13 @@ namespace BBM
const std::vector<std::vector<float>> moveDiag = {{-1, 0}, {-1, 1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1}};
const std::vector<float> rotationAngle = {0.0f, 45.0f, 90.0f, 135.0f, 180.0f, 225.0f, 270.0f, 315.0f};
const auto &controllable = entity.getComponent<ControllableComponent>();
auto &model = entity.getComponent<Drawable3DComponent<RAY3D::Model>>();
auto drawable = entity.getComponent<Drawable3DComponent>().drawable.get();
auto &animation = entity.getComponent<AnimationsComponent>();
auto anim = dynamic_cast<RAY3D::Model *>(drawable);
for (int i = 0; i != moveDiag.size(); i++) {
if (controllable.move.x == moveDiag[i][0] && controllable.move.y == moveDiag[i][1]) {
model.member.setRotationAngle(rotationAngle[i]);
if (anim)
anim->setRotationAngle(rotationAngle[i]);
animation.setAnimIndex(0);
return;
}