Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Feb 08, 2021 at 12:26 AM by koxu720 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by koxu720 · Feb 01, 2021 at 10:10 PM · movementplayerprogrammingbegginerdialog

How to stop player movement during dialog?,I don't know what i can write after "if" to stop player movement during dialog

I don't know what i can write after "if" to stop player movement during dialog referring to another script responsible for it, please help :(

using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro;

public class piotrekDialog : MonoBehaviour { public TextMeshProUGUI textDisplay; public string[] sentences; private int index; public float typingSpeed; public GameObject continueButton; public playerMovement playerMovementScript;

 void Start()
 {
     StartCoroutine(Type());
 }

 void Update()
 {
     if (textDisplay.text == sentences[index])
     {
         continueButton.SetActive(true);
     }

     if (textDisplay.text == sentences[index])

         playerMovementScript.playerControlsEnabled = false;
     else
     {
         playerMovementScript.playerControlsEnabled = true;
     }

     if (/* I don't know what to write here*/)
         playerMovementScript.playerControlsEnabled = false;
     else
     {
         playerMovementScript.playerControlsEnabled = true;
     }      
 }

 IEnumerator Type()
 {
     foreach (char letter in sentences[index].ToCharArray())
     {
         textDisplay.text += letter;
         yield return new WaitForSeconds(typingSpeed);
     }
 }

 public void NextSentence()
 {
     continueButton.SetActive(false);

     if (index < sentences.Length - 1)
     {
         index++;
         textDisplay.text = "";
         StartCoroutine(Type());
     }
     else
     {
         textDisplay.text = "";
         continueButton.SetActive(false);
     }
 }

},I don't know what i can write after "if" to stop player movement during dialog referring to another script responsible for it, please help :(

using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro;

public class piotrekDialog : MonoBehaviour { public TextMeshProUGUI textDisplay; public string[] sentences; private int index; public float typingSpeed; public GameObject continueButton; public playerMovement playerMovementScript;

 void Start()
 {
     StartCoroutine(Type());
 }

 void Update()
 {
     if (textDisplay.text == sentences[index])
     {
         continueButton.SetActive(true);
     }

     if (textDisplay.text == sentences[index])

         playerMovementScript.playerControlsEnabled = false;
     else
     {
         playerMovementScript.playerControlsEnabled = true;
     }

     if (/* I don't know what to write here*/)
         playerMovementScript.playerControlsEnabled = false;
     else
     {
         playerMovementScript.playerControlsEnabled = true;
     }      
 }

 IEnumerator Type()
 {
     foreach (char letter in sentences[index].ToCharArray())
     {
         textDisplay.text += letter;
         yield return new WaitForSeconds(typingSpeed);
     }
 }

 public void NextSentence()
 {
     continueButton.SetActive(false);

     if (index < sentences.Length - 1)
     {
         index++;
         textDisplay.text = "";
         StartCoroutine(Type());
     }
     else
     {
         textDisplay.text = "";
         continueButton.SetActive(false);
     }
 }

}

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
0

Answer by logicandchaos · Feb 02, 2021 at 12:55 AM

How do you know when there is a dialog? how do you start a dialog? If you have no way of telling make a bool isDialogMode; then when you start your dialog you add in isDialogMode=true; and when you leave dialog you add isDialogMode=false; then in your if you put isDialogMode.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

197 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Player movement for iOS? 1 Answer

2.5D Isometric Move Character and Facing towards mouse 0 Answers

Cannot dash in left-down, left-up and right-down directions? 2 Answers

How to make a good PlayerMovement 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges