Adding an Extra Collider #2731
-
Hi, My bomb object already has a collider so it stays on the floor, but when it explodes I want to add a circle collider so I can access the objects within the area it exploded. There is information about changing it in the document, but I want to add one more. (I saw the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I misunderstood the Trigger class a bit. The I tried adding an Actor instead: // Capture objects colliding with the circle.
const actor = new ex.Actor({
pos: this.pos,
radius: 45,
collisionType: ex.CollisionType.Passive,
collider: ex.Shape.Circle(50),
color: ex.Color.Black,
});
actor.on("postcollision", (ev) => console.log(ev));
this.scene.add(actor); But this way I can't listen to the collision event. Shouldn't |
Beta Was this translation helpful? Give feedback.
@cemalgnlts Good question, this is definitely the approach I would suggest for your bomb using another actor/entity with a circle collider. You could add an additional trigger/actor to the top level scene, or as a child on the bomb actor.
When the collision type is
ex.CollisionType.Passive
thepostcollision
event doesn't fire because no resolution was performed.You can use the
collisionstart
andcollisionend
events, here is an example of using this kind of approach to enable 1-way platforms.#2577 (reply in thread)
There is more documentation about the specific events here https://excaliburjs.com/docs/collision-events/#collision-start-collisionstart