How to call another method in a script from a different method

How to call another method in a script from a different method
0

i know about using .getComponent() but this method doesnt work for me since the method im calling inside that script has alotta this. usage so it messes up the whole thing. so my question is how can i call that method from another script but make it run as if it was being called inside the script itself?

i know its very complicated but i tried my best to explain as best i could :frowning:

So if I understood you correctly, you would like to do something like the following:

Parts of Script A:

properties: {
    something: false,
}

a(){
    this.something = true;
}

Parts of script B:

b(){
    (Script A access).a();
}

If you want to change the something property of A, you should be good with
node.getComponent(“A”).a();
(At least this works for me).
If you want the method a() to change properties in B, think about adding a parameter to a() to indicate what script you want to refer to.

1 Like

yes you got me right but basically its a lot more complicated than this and its a whole lots of referencing other nodes and things like that so i guess ill have to rewrite the function from beginning :frowning: Thanks for the help