precollision doesn't fire on Actor

11 views
Skip to first unread message

Thomer Gil

unread,
May 11, 2020, 6:22:31 PM5/11/20
to excaliburjs
Take a look at https://vimeo.com/417381980, showing the game Paratrooper. The canon fires missiles into the top left corner. Helicopters coming from the right that fly into the firing line correctly fire a precollision event. Helicopters from the left do not; they don't emit a precollision event. My only two theories are that, either, 1) if the box isn't fully in the screen, no collision events can occur yet, or 2) the missile that hits the helicopter needs to have been added to the scene *after* the helicopter was added to the scene.

But both of these theories sound absurd.

Do you have an intuition what might be going on? Both actors use colliding type Passive.

Relevant code below. Note that no 'precollision' logs appear on the console for helicopters coming from the left. (And, yes, it's the exact same code that makes helicopters appear either from the left or right; they only differ in the initial position,velocity, and sprite.)

        this.on('precollision', (ev) => {
            console.log('precollision');
            if (ev.other instanceof Missile) {
                this._explode();
            }
        });


Thanks.

Erik Onarheim

unread,
May 11, 2020, 7:07:59 PM5/11/20
to Thomer Gil, excaliburjs
That is odd I'm not sure what would be causing that, definitely a bug.

Definitely open an issue 👍

--
You received this message because you are subscribed to the Google Groups "excaliburjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to excaliburjs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/excaliburjs/484086f6-b686-45da-b8e7-a05ce95e118d%40googlegroups.com.

Thomer Gil

unread,
May 11, 2020, 7:46:02 PM5/11/20
to excaliburjs
Erik, thanks for the quick response.

As part of trying to create an issue and, thus, trying to narrow down the problem, I discovered what the problem is. And I'm posting it here for prosperity's sake. It appears that setting the collider in the helicopter's on('initialize', ...) is at least part of it. If I move as much as possible to the helicopter's constructor, the problem goes away.

Thank you again.

On Tuesday, May 12, 2020 at 1:07:59 AM UTC+2, Erik Onarheim wrote:
That is odd I'm not sure what would be causing that, definitely a bug.

Definitely open an issue 👍

On Mon, May 11, 2020, 17:22 Thomer Gil <thom...@gmail.com> wrote:
Take a look at https://vimeo.com/417381980, showing the game Paratrooper. The canon fires missiles into the top left corner. Helicopters coming from the right that fly into the firing line correctly fire a precollision event. Helicopters from the left do not; they don't emit a precollision event. My only two theories are that, either, 1) if the box isn't fully in the screen, no collision events can occur yet, or 2) the missile that hits the helicopter needs to have been added to the scene *after* the helicopter was added to the scene.

But both of these theories sound absurd.

Do you have an intuition what might be going on? Both actors use colliding type Passive.

Relevant code below. Note that no 'precollision' logs appear on the console for helicopters coming from the left. (And, yes, it's the exact same code that makes helicopters appear either from the left or right; they only differ in the initial position,velocity, and sprite.)

        this.on('precollision', (ev) => {
            console.log('precollision');
            if (ev.other instanceof Missile) {
                this._explode();
            }
        });


Thanks.

--
You received this message because you are subscribed to the Google Groups "excaliburjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to excal...@googlegroups.com.

Erik Onarheim

unread,
May 12, 2020, 9:20:50 AM5/12/20
to Thomer Gil, excaliburjs
Good detective work!

I've made a bug about this, setting up colliders in the initialize should work.
https://github.com/excaliburjs/Excalibur/issues/1542  

Do you have a small snippet you can share with me to reproduce this issue?

To unsubscribe from this group and stop receiving emails from it, send an email to excaliburjs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/excaliburjs/bbb1bd43-c45e-410b-9469-f3eaee7b27b2%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages