Hello, I’m a bit new to Playcanvas and I have a problem with my game. So basically, I want a dialogue to pop up via the 2D Screen when my character collides with a certain object: For example: I want a dialogue to pop up when my character hits the object intwalis (indicated both in the scene and the script). But when I applied this code:
CollisionStart.prototype.initialize = function() {
this.entity.collision.on('collisionstart',this.onCollisionStart,this);
var Dialogue = this.app.root.findByName("dialogue");
Dialogue.element.text = String();
//function for onCollision start
CollisionStart.prototype.onCollisionStart = function(result){
if(result.other.name == 'intwalis'){
var Dialogue = this.app.findByName("dialogue");
Dialogue.element.text = String ("Oohh~ Walis Tambo! Are you going to sweep? Interact with the object to do so!");
It says an error “Uncaught TypeError: this.app.findByName is not a function”
Here is a screencap to the script used.
Here is also a link to the game. I hope I can get some help. Thank you.
https://playcanvas.com/editor/scene/1472900