Hi! It only worked for the rat, but for the other objects, they don’t appear even when triggered by the collision. I tried it with the ones that are not part of the circle. The figures on the corners has pop up infoboxes but they don’t show up.
Hi! It only worked for the rat, but for the other objects, they don’t appear even when triggered by the collision. I tried it with the ones that are not part of the circle. The figures on the corners has pop up infoboxes but they don’t show up.
Do you know what might be wrong in my code? Thanks so much!
It seems you already solved the problem by changing result.other.name to result.name on collisionend. It remains difficult to remember when you should and should not use other.
Yes, but for some reason, it doesn’t work with the others. It only works with certain animals, but doesn’t work with everything. Do you know what might be wrong?
Here’s my code so far:
FirstPersonView.prototype.OnCollisionEnter = function(result){
if (result.other.name == "ZodiacRat") {
this.app.root.findByName("infobox").enabled = true;
}
if (result.other.name == "ZodiacPig") {
this.app.root.findByName("infobox1").enabled = true;
}
if (result.other.name == "ZodiacDragon") {
this.app.root.findByName("infobox2").enabled = true;
}
if (result.other.name == "ZodiacHare") {
this.app.root.findByName("infobox3").enabled = true;
}
if (result.other.name == "ZodiacOx") {
this.app.root.findByName("infobox4").enabled = true;
}
if (result.other.name == "ZodiacSnake") {
this.app.root.findByName("infobox5").enabled = true;
}
}
FirstPersonView.prototype.OnCollisionend = function(result){
if (result.name == "ZodiacRat") {
this.app.root.findByName("infobox").enabled = false;
}
if (result.name == "ZodiacPig") {
this.app.root.findByName("infobox1").enabled = false;
}
if (result.name == "ZodiacDragon") {
this.app.root.findByName("infobox2").enabled = false;
}
if (result.name == "ZodiacHare") {
this.app.root.findByName("infobox3").enabled = false;
}
if (result.name == "ZodiacOx") {
this.app.root.findByName("infobox4").enabled = false;
}
if (result.name == "ZodiacSnake") {
this.app.root.findByName("infobox5").enabled = false;
}
}```