The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

I made a simple dialog system, and I wanted that when the dialog was happening the Player would stop, so I made a variable in the Player that it could only move when this variable was FALSE, but I wanted to be able to enable the NPC to enable it when it starts the dialog and disable at the end.

Godot version latest
in Engine by (26 points)

2 Answers

0 votes

It's worth learning about signals

https://www.youtube.com/watch?v=NK_SYVO7lMA

Although it turns out connecting a signal to another scene is a bit more work than i expected.

How does the player trigger the NPC? Is there an CollisionShape? If so you can call a function on the body that is detected.

So add this to the player

func npc_talking(is_talking):
    cant_move = is_talking

Then call it passing a true of false from your detection code.

by (53 points)
edited by
0 votes

You could use a Singleton in an autoload. Make a script named "Global" and attach it to a Control or Node2D, then autoload that in settings. (The object, not the script)

Then it's as simple as this:

var _currentCutScene = false ## you can name this whatever

Then a simple check in your character's movement, you can also put an extra variable there if you'd like. This is usually a good idea with singletons because calling them is a reference unless yo are directly changing it. If the bool is true, don't allow movement.

if _currentCutScene == true:
     _canMove = false

Then plug that into whatever functions you want to disable.

by (562 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.