Wednesday, November 4, 2015

Day 73: Boosting and Blasting the Salmon Armada

Today marked a great start to our RPP thus far! After consultation regarding calibration of accelerometer input, I set both a low pass filter to take out noise values (fancy term, but a linear interpolation with a set factor to reduce large values) and also took the average of the first 10 frames of acceleration for a relative factor that can be used for movement.

We decided to go with only one axis of movement for moving the ship with the accelerometer; the z axis looked as if it would work but oddly enough, the x axis is most responsive when working in Landscape orientation.

Things did get a bit tricky, however; the acceleration took awhile to catch up, especially with quick jerking movements. The application of a force, even a small one, felt like it dragged on. In response, I actually dropped the Rigidbody2D and set the position based on a clamped min/max accelerometer input. The max (0.5, for example) would be the top of the screen, while the min (-0.5) translated to the bottom of the screen. This ensures a relatively quick input without fighting with a rigidbody's movement dynamics.

As for the bullets, I used Spherical interpolation again (Sluuurp) to naturally aim the ship where the finger was being pressed, and I added a bit of the spin to the bullets to give them a little more appeal. I did run into an (obvious) problem when I had forgotten to set the player's child objects' local positions to the origin, which led to quite the mishap involving the ship rotating around an entirely different point in space.

I also put in some buttons for boosting forward and backward. The ship has a natural deceleration that pushes it back to a starting point, but the boost allows a faster jump forward and backward. This input was especially tricky, as I had to specify if the touch was on or off the button before I could shoot; Input.GetTouch(0) was no longer an option. Luckily enough, the touch list is a short one for iteration, so iterating through them and taking the first one that wasn't on a button worked well, allowing multi-touch input.



Next up? Watery areas; the salmon gotta swim through something.

No comments:

Post a Comment