Quantcast
Channel: Questions in topic: "framerate drops"
Viewing all articles
Browse latest Browse all 141

2D Board Game Movement Script Results in Empty Calculations

$
0
0
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().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.

Viewing all articles
Browse latest Browse all 141

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>