feat: fully implemented death in NpcUnit
This commit is contained in:
parent
5f61fafe7b
commit
28183fceb8
4 changed files with 43 additions and 8 deletions
|
|
@ -19,11 +19,15 @@ void EnemyBody::on_child_added(Node *node) {
|
|||
void EnemyBody::ready() {
|
||||
this->fsm = cast_to<StateMachine>(get_node(NodePath("%StateMachine")));
|
||||
this->nav = cast_to<NavigationAgent3D>(get_node(NodePath("%NavigationAgent3D")));
|
||||
this->health = cast_to<HealthStatus>(get_node(NodePath("%HealthStatus")));
|
||||
}
|
||||
|
||||
void EnemyBody::physics_process(double delta) {
|
||||
GETSET(velocity, {
|
||||
velocity = Vector3{ this->movement_direction.x * this->movement_speed, velocity.y, this->movement_direction.y * this->movement_speed } + (velocity * delta);
|
||||
if (!is_on_floor() && this->health->get_health() > 0) {
|
||||
velocity += get_gravity() * delta;
|
||||
}
|
||||
});
|
||||
if (!this->movement_direction.is_zero_approx()) {
|
||||
look_at(get_global_position() + Vector3{ this->movement_direction.x, 0.f, this->movement_direction.y });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue