I’m trying to make a game where when a ball goes through a hoop and passes through a trigger it changes a score variable by +1 and updates a text thing to display the score. When the ball passes through it I’m also trying to make the trigger teleport the ball to the center of the map. I have started a script to teleport the ball I found from another forum but I could not get it to work.
What I have so far:
var Teleport = pc.createScript('teleport');
// initialize code called once per entity
Teleport.prototype.initialize = function () {
this.entity.collision.on('triggerleave', this.onTriggerLeave, this);
console.log('did thing');
this.teleportPoint = this.app.root.findByName('TeleportPoint');
};
Teleport.prototype.onTriggerleave = function (result) {
if (result.other.rigidbody) { result.other.rigidbody.teleport(teleportPoint);
}
};
Would appreciate help thanks