I have 2 things I need help with
- Turning on and off scripts from a separate script
- Freezing an entity in place so you apply tons of force and blast off
if anyone can help with one or both of these I’m all ears
Sincerely William Boersma
I have 2 things I need help with
if anyone can help with one or both of these I’m all ears
Sincerely William Boersma
Hi William!
First of all, make sure to read the documentation about the pc.Entity: https://developer.playcanvas.com/en/api/pc.Entity.html#script
There you can learn all the properties and methods you can access from any entity in your game.
otherEntity.script.enabled = false;
//Disable the pc.ScriptComponent of "otherEntity".
otherEntity.script.scripts[index].enabled = false;
//Disable a specific script
I think you also need to define an object where the script is attached on in initialize.
ex.:
this.ObjectWithScript = this.app.root.findByName('ObjectWithScriptAttached');
and use this.ObjectWithScript.script.enabled = false;
in specific part of code you want
I used finding by name, but you can also find object by tag or with other methods you can see in documentation.
The way of freezing entities is to set this.app.timeScale = 0;
but to freeze one entity it depends whether you using physics or just translate
method.
https://developer.playcanvas.com/en/api/pc.Application.html#timeScale
never Mind I got it