aboutsummaryrefslogtreecommitdiff
path: root/src/entities/maresciallo.c
diff options
context:
space:
mode:
authornathansmithsmith <nathansmith7@mailfence.com>2023-08-03 00:11:48 -0600
committernathansmithsmith <nathansmith7@mailfence.com>2023-08-03 00:11:48 -0600
commit6d7842484434d1d3f4265194ba87db6afff3186b (patch)
tree07d9307c500ae47c9c250a2cb8ec24104c78a94b /src/entities/maresciallo.c
parent7259478c55bcf1eb717ee1b846522121ef5fd7f3 (diff)
Working on circle thingy
Diffstat (limited to 'src/entities/maresciallo.c')
-rw-r--r--src/entities/maresciallo.c14
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);