When I add the same pickup script to another object it breaks the script, and I can’t pick anything up
https://playcanvas.com/project/1281715/overview/blank-project
When I add the same pickup script to another object it breaks the script, and I can’t pick anything up
https://playcanvas.com/project/1281715/overview/blank-project
Can we have more information?
Hi @playcanvas20122 and welcome!
If you mean the Box entity, than that’s probably because the components of the entity are disabled at the moment.
Otherwise, a little bit more information would be helpful.
sorry, I mean the chrome ball entity and the little white ball. I have the script pickUpObject.js on both but if I disable it on one of the two it will pickup the object succesfully
Should etoggle be global? Try putting it in initialize
I’m on mobile at the moment, so I can’t check the project. If I look at the script, I think the problem is indeed the global variable etoggle
. For example line 39 will probably override the possibility for another entity.
Yeah that would make a lot of sense if they both are triggering etoggle to flip values at the same time
I think if you apply the suggestion of @ALUCARD correctly, it should work. Make sure you create a variable this.etoggle
in the initialize function and replace every etoggle
with this.etoggle
.
Ohhhh… this works, thank you
This works, I just didn’t apply it correctly, which Albertos corrected, thank you ALUCARD