0
Answered

How to use Call Method?

Oliver Marshall 2 months ago in Game Creator updated by Marti (Lead Developer) 2 months ago 1

Hi all

What's the correct way to use the Call Method action to call a method from a custom script? I want to have my 2D player prevented from moving during dialogues, so I thought I'd use Call Method to call a method in my player controller at the start of the dialogue to disable movement, and again after the dialogue to enable it.

However it doesn't work, and I can't see that the Call Method is even being actioned. 

My method in my script is this:

public void StopMovement() { print("Stopping Movement !!!!!!!!!!!!!"); }

 My Call Method action shows this. When I select the script name from the asset list it immediately changes it to the name of the public function. I'm not sure if this is by design, as it's the only public method, or a bug. 

I've tried it with and without the StopMoving string in MonoScript.name.

No matter what I do the PRINT line in the public method is never actioned, though it works if I call it from another custom script.

Any ideas?

Unity version:
Game Creator version:

Answer

Answer
Answered

Your StopMoving script must be attached to a game object. Then, drag that game object onto the Call Method's bottom field and the dropdown should provide a list of all available components in that game object. Choose your component name and select the "Stop Moving" method.

Answer
Answered

Your StopMoving script must be attached to a game object. Then, drag that game object onto the Call Method's bottom field and the dropdown should provide a list of all available components in that game object. Choose your component name and select the "Stop Moving" method.