Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by Fuhans · Dec 11, 2013 at 02:21 PM · c#turn-based

Disable the GUI when the character moving

Hai everyone, i already make the player character to move to it is destination (animate the character to move to that destination), i wanted to disable the GUI button when the player character is moving, but i can't get it and work it out. Could you guys help me?

Here is the code:

 public class UserPlayer : Player 
 {
     public override void TurnUpdate()
     {
         //Moving animation
         if (positionQueue.Count > 0) 
         {
                     GUI.enabled = false; // This is the one that i want when the character still moving (animation still moving), disabled the GUI. But i can't get it
             transform.position += (positionQueue[0] - transform.position).normalized * moveSpeed * Time.deltaTime;
             
             if (Vector3.Distance(positionQueue[0], transform.position) <= 0.1f) 
             {
                 transform.position = positionQueue[0];
                 positionQueue.RemoveAt(0);
 
                 if (positionQueue.Count == 0) 
                 {
                     actionPoints--;
                 }
             }
         }
         
         base.TurnUpdate();
     }
     
     public override void TurnOnGUI() 
     {
         base.TurnOnGUI();
     }
 }

 public class Player : MonoBehaviour 
 {
 //movement animation
     public List<Vector3> positionQueue = new List<Vector3>();

 public virtual void TurnUpdate()
     {
         if (actionPoints <= 0) 
         {
             actionPoints = 2;
             magicAttacking = false;
             moving = false;
             attacking = false;            
             GameManager.instance.NextTurn();
         }
     }

      public virtual void TurnOnGUI()
       {
         if (GameManager.instance.currentPlayerIndex == 0 || GameManager.instance.currentPlayerIndex == 2)
         {
             //ToolTip Text
     move = GUI.Button(buttonRect, new GUIContent("Move", "Move the Player"));
     GUI.Label(tooltipRect, GUI.tooltip, label1);

     GUI.tooltip = null;

     //Move Button
     if (move)
     {
         if (!moving)
         {
             GameManager.instance.RemoveTileHighlights();
             moving = true;
             attacking = false;
             GameManager.instance.HighlightTilesAt(gridPosition, Color.blue, movementPerActionPoint);
         }

         else
         {
             moving = false;
             attacking = false;
             GameManager.instance.RemoveTileHighlights();
         }
     }
         }

Thank you

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Vandarthul · Dec 11, 2013 at 04:21 PM

declare a bool under your class and true it when the character is moving and add this code(you will have to false the bool when the character is stopped moving too):

 if(isOnMove)
 {
 move = GUI.Button(buttonRect, new GUIContent("Move", "Move the Player"));
     GUI.Label(tooltipRect, GUI.tooltip, label1);
 }
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
avatar image
0

Answer by Aladine · Dec 11, 2013 at 03:50 PM

you are making it a lot more complicated than it needs to be, do it like that ; create a bool var, it get false when the player is moving (obviously when there is an input key down) and you draw your gui when that variable is true

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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

18 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

Related Questions

Distribute terrain in zones 3 Answers

Need help cycling through an array with a 'for' loop. 0 Answers

On Mouse Click Button event 0 Answers

Turn Based RPG Combat System Style Game 0 Answers

Center camera on object in unity3d by programatically 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