diff options
Diffstat (limited to 'src/entities/maresciallo.c')
-rw-r--r-- | src/entities/maresciallo.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/entities/maresciallo.c b/src/entities/maresciallo.c index f447819..288b27e 100644 --- a/src/entities/maresciallo.c +++ b/src/entities/maresciallo.c @@ -20,7 +20,7 @@ void initMaresciallo(Entity * entity, Game * game) { Maresciallo * data = (Maresciallo*)entity->data; PIDConfig flyAwayPID = (PIDConfig){ - .kP = 1.1, + .kP = 100, // 1.1 .kI = 0.0, .kD = 0.0, .angleMode = false, @@ -61,8 +61,18 @@ void getAwayMaresciallo(Game * game, Entity * entity) { } void circlePlayerMaresciallo(Game * game, Entity * entity) { + float t = GetFrameTime(); Maresciallo * data = (Maresciallo*)entity->data; Entity * player = getEntityFromWorld(game->world, 0); + + Quaternion toEntity = QuaternionFromVector3ToVector3(player->position, entity->position); + Quaternion next = toEntity; + next = QuaternionIdentity(); + + Vector3 target = Vector3Subtract(entity->position, player->position); + target = Vector3RotateByQuaternion(target, next); + + entity->position = Vector3Add(player->position, target); } void updateMaresciallo(Game * game, Entity * entity) { @@ -72,7 +82,7 @@ void updateMaresciallo(Game * game, Entity * entity) { Entity * player = getEntityFromWorld(game->world, 0); // Fly away if to close to player. - if (Vector3Distance(entity->position, player->position) < MARESCIALLO_CIRCLE_AT_DIS) { + if (Vector3Distance(entity->position, player->position) < MARESCIALLO_CIRCLE_AT_DIS - 1) { getAwayMaresciallo(game, entity); } else { circlePlayerMaresciallo(game, entity); |