checkpoint
Permet de changer le point d'apparition des joueurs lorsqu'ils perdent
triggers on self
"checkpoint off""checkpoint on"triggers on others
"checkpoint"parameters
| Parameter | Default Value | Type | Description |
|---|---|---|---|
onInteract | boolean | false | |
forAllPlayer | boolean | true | |
tag | string | 'player' |
example
checkpoint({ onInteract: false, forAllPlayer: true, tag: 'player'}),function checkpoint(p) { const param = { onInteract: false, forAllPlayer: true, tag: 'player', ...p, }; return { animAmp: 0, animStart: 0, id: 'checkpoint', isCheckPointActivated: false, add() { if (param.onInteract) { this.tag('interactive'); this.on('interacted', (obj) => this.activateCheckPoint(obj)); } else this.onCollide(param.tag, (obj) => this.activateCheckPoint(obj)); }, activateCheckPoint(obj) { if (obj.has('respawn') && !this.isCheckPointActivated) { this.isCheckPointActivated = true; if (param.forAllPlayer) for (const t of get(param.tag, { recursive: true, })) { t.setInitPos(this.worldPos); } else obj.resetPos = this.worldPos; for (const e of get('checkpoint', { recursive: true, })) if (e != this) { e.isCheckPointActivated = false; e.trigger('checkpoint off'); } this.trigger('checkpoint on'); obj.trigger('checkpoint'); } }, };}