Commit, fix boxcollider
This commit is contained in:
@@ -8,5 +8,7 @@
|
||||
|
||||
namespace Game::AGame {
|
||||
GAME_ENTITY(Enemy)
|
||||
public:
|
||||
void onCollisionEnter(Object::Entity* other) override;
|
||||
END_GAME_ENTITY()
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <object/components/component.hpp>
|
||||
#include <state/gamestate.hpp>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace Game::Object::Components {
|
||||
struct BoxColliderBounds {
|
||||
@@ -21,10 +22,10 @@ namespace Game::Object::Components {
|
||||
void update(float deltaTime, Object::Entity* thisEntity) override;
|
||||
|
||||
BoxColliderBounds getBounds() const { return mBounds; }
|
||||
bool isColliding() const { return mIsColliding; }
|
||||
bool isColliding() const { return !mCollidingWith.empty(); }
|
||||
|
||||
private:
|
||||
BoxColliderBounds mBounds;
|
||||
bool mIsColliding = false; // Whether this collider is currently colliding with another collider; used to determine whether to call onCollisionEnter vs onCollisionStay, and to call onCollisionExit when collisions end
|
||||
BoxColliderBounds mBounds{0.f, 0.f, 0.f, 0.f};
|
||||
std::unordered_set<Object::Entity*> mCollidingWith; // Track collisions per-entity so enter/stay/exit callbacks remain correct with multiple colliders
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user