Vector Grid and Optimization

posted in: Senior Team | 0

PlainRipplesWith the gameplay solidified, we wanted to add more to the environment of our game. Since the concept of the game revolves around entity’s jumping on the surface of the water, we wanted to project that to the player. One of the ways we thought of was having the ripples interact with the background as they pass over it. After we talked it over, we figured that some kind of grid that the ripples interacted with on the background would be useful. Similar to how all the entities interact with the background in Geometry Wars. After weighing the positives and negatives of making our own interactable grid we decided to make use of Vector Grid. The original implementation into our game was fairly straight forward testable right away.Grid

Instead of having it display as a grid, we decided to test out a few different background textures since Vector Grid had support for that. We wanted to keep the geometry theme we had so far in the game so we opted for testing out backgrounds with geometric shapes.bluetilesExample orangetilesExample flowertilesExample

Some backgrounds worked out better than others. Some were just way too busy and we were looking for a subtle background since the game can already get pretty hectic in some of the faster parts of the songs. As of this point we have decided to go with a subtle background grid that fades in and out of

Vector Grid is simple and easy to use. You put a vector grid into the scene and set it to the size you want. To get objects to interact, you just need to add a vector grid force to the object. So what we did was add a vector force to each of the points on a ripple. What we found was that the game initially ran fine during the testing. But those computers were more powerful than what we have. So when it was PI, who generates circles, versus DELTA, who creates diamonds, the framerate started to drop with each consecutive ripple that was generated. With PI at roughly 52 points to get a nice circle shape, and each point having a force to interact with the grid, that became taxing on the framerate.

So I made a simple way for us to control the number of forces on a ripple.


On the ripple script there is a value set the number of points a ripple has. The higher the points, the more it looks like a circle. Below that is a value to cull the number of forces. How it works is this. If I have 52 points, and the cull value of 5, It would generate a force object for every fifth point on the ripple once the button was pressed. After the forces are added to the ripple game object, you just apply it to the prefab and it will work for the rest of the ripples of that type.

This greatly reduced the number of force calculations that our grid needed to do and brought our game back up to 60fps on our slower machines.
-Jack Storm