So basically, Im going to start coding again and im pretty stuck. Im trying to learn code and all but im a bit stuck on a disappear script. My code so far:
var Disappear = pc.createScript('disappear');
var pin;
var ball;
// initialize code called once per entity
Disappear.prototype.initialize = function() {
};
// update code called every frame
Disappear.prototype.update = function(dt) {
if pin.gets.hit.byBall =
};
this.app.root.findByName("Ball")
// swap method called for script hot-reloading
// inherit your script state here
// Disappear.prototype.swap = function(old) { };
// to learn more about script anatomy, please read:
// http://developer.playcanvas.com/en/user-manual/scripting/
Im trying to make pins disappear after a bowling ball hits them, pretty basic so far and im failing
Hey, if I had to do it, I would do it like this
Ball:
// initialize code called once per entity
Collider.prototype.initialize = function () {
this.entity.collision.on("contact", this.onContact, this);
};
Collider.prototype.onContact = function (result) {
if (result && result.other.tags.has('Pin')) {
if (result.other.enabled == true) {
result.other.enabled = false;
}
}
};
Then, we add the βPinβ tag to all the pins
More about collision and triggers:
https://developer.playcanvas.com/en/tutorials/collision-and-triggers/
3 Likes
Completely forgot about this, thanks for helping me!
tried copying out the code and the error i get is:
it may be simple but i am a beginner
@Gabriel_Dobrzynski Is there a chance for you to share your project?