#include "soldato.h" #include "game.h" void initSoldato(Entity * entity, Game * game) { entity->model = &game->assets.models[SOLDATO_ASSET]; } void closeSoldato(Entity * entity) { } void updateSoldato(Game * game, Entity * entity) { Entity * player = getEntityFromWorld(game->world, 0); // Get direction. Vector3 direction = Vector3Subtract(entity->position, player->position); direction = Vector3Normalize(direction); // Get look at and rotation. Matrix matrix = MatrixLookAt(Vector3Zero(), direction, (Vector3){0, 1, 0}); Quaternion rotation = QuaternionFromMatrix(matrix); rotation = QuaternionInvert(rotation); entity->rotation = rotation; entity->velocity.velocity = Vector3Scale(direction, -10.0); entityUpdatePosition(entity); } void drawSoldato(Game * game, Entity * entity) { entityDraw(entity); }