onTriggerEnter not detected

the trigger is not detected on contact with car, I mean no console.log when the car reaches the trigger

/*jshint esversion: 6 */


class Trigger extends pc.ScriptType {

    // initialize code called once per entity
    initialize() {
        this.entity.collision.on('triggerenter', this.onTriggerEnter, this);
        console.log('trigger', this.entity);
    }
    onTriggerEnter(entity) {

        console.log('contact with road');
        entity.getPosition().y += 0.2;

    }
}

pc.registerScript(Trigger, 'trigger');

Hi @grzesiekmq,

Your code seems correct, so I imagine your editor/entities setup may have some error.

Can you provide a sample project url to take a look? But please if you are able one that doesnā€™t have 1M polygons of models, loads quickly :innocent:

ok it was rigidbody dynamic (incorrectly) of car not kinematic

1 Like