Skip to content

Commit

Permalink
Added AABB collider to zombie
Browse files Browse the repository at this point in the history
  • Loading branch information
kraifpatrik committed Apr 11, 2022
1 parent 34c5f7f commit 6764773
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 1 addition & 4 deletions BBMOD_GML/objects/OPlayer/Step_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ if (global.gameSpeed > 0.0)

// Determine which enemy was shot using a raycast against an AABB at its position.
var _ray = new BBMOD_Ray(camera.Position, camera.get_forward());
var _aabb = new BBMOD_AABBCollider(undefined, new BBMOD_Vec3(5, 5, 18));

with (OZombie)
{
Expand All @@ -107,9 +106,7 @@ if (global.gameSpeed > 0.0)
continue;
}

_aabb.Position.Set(x, y, z + 18);

if (_aabb.Raycast(_ray))
if (collider.Raycast(_ray))
{
ReceiveDamage(irandom_range(45, 55));

Expand Down
5 changes: 5 additions & 0 deletions BBMOD_GML/objects/OZombie/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ event_inherited();

z = global.terrain.get_height(x, y) ?? 0.0;

// Used to raycast shots from the player's gun.
collider = new BBMOD_AABBCollider(
new BBMOD_Vec3(x, y, z),
new BBMOD_Vec3(5, 5, 18));

ReceiveDamage = function (_damage) {
hp -= _damage;
hurt = 1.0;
Expand Down
2 changes: 2 additions & 0 deletions BBMOD_GML/objects/OZombie/Step_2.gml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ animationStateMachine.AnimationPlayer.Paused = (hurt > 0.25);

event_inherited();

collider.Position.Set(x, y, z + 18);

if (destroy)
{
instance_destroy();
Expand Down

0 comments on commit 6764773

Please sign in to comment.