Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
This question was closed May 04, 2016 at 03:24 AM by NoHomeLike192_168_8_1 for the following reason:

Problem was solved.

avatar image
0
Question by NoHomeLike192_168_8_1 · May 03, 2016 at 07:31 PM · movement scriptboardgameframerate drops

2D Board Game Movement Script Results in Empty Calculations

Okay, so I have a function that generates a list of possible moves one can make. From this function, tiles are overlaid with a blue highlight. When clicked, this highlight should move the selected character, provided there are no enemy characters on it, to the tile.

     void OnMouseOver() //Snippet from the Movement Highlight's attached script
     {
         print("Get off of me!");
         if(Input.GetMouseButtonUp(0) && !UIMan.UIActive) 
         //if we left-click and we aren't drawing any menus
         {
             print("!HERE!");
             if(overlaidOver.stoodOnBy == null) //if no character stands on this tile
             {
                 PersonThisBelongs.StandingOn.stoodOnBy = null; 
                 //the tile the selected character is standing on: no longer stood on

                 PersonThisBelongs.gameObject.transform.position = 
                 overlaidOver.gameObject.transform.position;
                 //set the character's position to that of the clicked-on highlight square

                 PersonThisBelongs.StandingOn = overlaidOver;
                 //the character is now standing on this tile

                 overlaidOver.stoodOnBy = PersonThisBelongs.gameObject;
                 //the tile is now stood on by the character

                 PersonThisBelongs.canMove = false;
                 //the character can no longer move this turn

                 GameMan.CloseEye(); //removes any pathfinding data and deselects the character
                 //Move the character to that tile
             }
             else if(!overlaidOver.stoodOnBy.GetComponent<Character>().team && 
              overlaidOver.stoodOnBy != PersonThisBelongs) 
               //if we are clicking on someone on our team
               //& they are not the one we have selected
             {
                 GameMan.CloseEye();
                 GameMan.TheEyeIsWatching(overlaidOver.stoodOnBy);
                 //call the deselection cleanup method
                 //select the new character
             }
         }
     }

UIActive is false, but we don't even reach the second print statement. Also, when a movement highlight square is clicked, the game drops to about 30 fps for a split second presumably doing calculations before spitting out nothing. The movement highlight, tiles they are over, and the characters all have 2d box colliders attached to them.

I can provide other snippets of code if they would be helpful, but this is the problem function at the moment.

Comment
Add comment · Show 1
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 NoHomeLike192_168_8_1 · May 04, 2016 at 03:23 AM 0
Share

Ahhh... it turns out I was setting what the highlights were overlaid over to the character's position, so the game freaked out when I tried to move it there.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

53 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

Related Questions

How to make the 2D board game piece move only when the player answers the question correctly? 0 Answers

How can I make these accomplishments in my situation? 1 Answer

(2D) My Character wont stop moving/sliding when I let go of the button 1 Answer

How do I make a centipede/conga line out of game objects? 0 Answers

Movement acceleration 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