Hello, I am trying to execute the log() function onTriggerEnter. So when something collides with the entity this script is set to, it executes a message saying that it has detected a collision via console.
here is my code:
---snip---
//this code is the code not working, supposed to execute when something collides with this entity.
Trigger.prototype.onTriggerEnter = function(entity) {
entity.rigidbody.linearVelocity = pc.Vec3.ZERO;
entity.rigidbody.angularVelocity = pc.Vec3.ZERO;
// display a message after collision via console.
console.log('I have detected a collision!');
};
---snip---
I do have everything defined/set, and collision is on, as this is the beginning of my code:
// initialize code called once per entity
Trigger.prototype.initialize = function() {
this.entity.collision.on('triggerenter', this.onTriggerEnter, this);
};
I do not know if I need to apply this
to the front of any of the functions, but I would appreciate help!