I have trigger.js and BumpPositions.js
/*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('trigger', this.entity);
and part of BumpPositions.js
fixPos(pos){
if(this.app.keyboard.wasPressed(pc.KEY_Y)){
this.data.
but I’m stuck at find the current trigger which reacted with ontriggerenter in my array, maybe because I dont know the index of trigger position
and there modify Y of pos
when I do console.log('trigger', this.entity);
I have the trigger
so add to array each trigger name or update the position not in array but position which was set on trigger entity then push all trigger positions into array?
Like the position was set so entity has position 0,0,0 for example etc.
and next I replace existing array with updated positions
generally this.data
is looks like this
[{x: -644.7719116210938, y: 3.1999998092651367, z: -176.37185668945312},
{x: -643.83935546875, y: 3.3999996185302734, z: -180.26043701171875}, ... ]
so this is the position of trigger1 next position of trigger2 and so on
I mean array[0] trigger1
array[1] trigger2
so add name of trigger property? like {x: -644.7719116210938, y: 3.1999998092651367, z: -176.37185668945312, name: 'trigger1'}
I mean to update position of trigger which wasn’t yet set or update position of trigger which was set?
which wasnt set I mean
[{x: -644.7719116210938, y: 3.1999998092651367, z: -176.37185668945312},
{x: -643.83935546875, y: 3.3999996185302734, z: -180.26043701171875}, ... ]
so there are only positions
and which was set I mean the trigger with position like entity has position
what I want in short?
I drive the car into trigger position then get ontriggerenter event and next I want to know which trigger or the name of trigger car reaches so then I can fix the Y coord and the car automatically updates with trigger pos Y