From 6d7842484434d1d3f4265194ba87db6afff3186b Mon Sep 17 00:00:00 2001 From: nathansmithsmith Date: Thu, 3 Aug 2023 00:11:48 -0600 Subject: Working on circle thingy --- src/entities/maresciallo.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/entities/maresciallo.c') 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); -- cgit v1.2.3