fredag 9 maj 2014

The week of XInput, Checkpoints and "Destructible objects"

The week has come to an end, and for once I thought I whould get this blogging thing out of the way in time, so here I am.
This week I've been doing alot of different things, I re-did how the checkpoint boosts worked, I implemented XInput, a Xbox controller library. I linked our multiplayer lobby to the actual gameplay so the multiplayer works, and a lot more.

Checkpoints

So we got some feedback during the alpha, and one feedback we got was a smal amount of players didn't get the checkpoint boosts we had. In this checkpoint system you hold down a button to charge a boost, and then when you release you gain the momentum you've charged up. So to simplify this we decided to redo them so that they charged themselfs and when you pressed the button you got the momentum.
I personally didn't like this change, since I feelt that we keept the player passive and the charging lost its charm when you didn't charge it youself, but I still decided to give it a chance. So I changed the checkpoint boost to how we decided and we tried it on some people, and none of them liked the changes we did to them.
As I feared I made the player passive, and we decided to revert them to the way they were before. I think that people will understand this system when it's explained to them: "hold button-charge, release-get speed" is not that hard to get.



XInput

XInput is a library for Xbox controlls "But David, you are making your game in Unity doesn't that already have controller support!? Are you a moron!?" Glad you asked random person on the internet, yes we are making our game in the Unity engine and yes it has controller support, BUT it doesn't have full controller support since it can't make a controller vibrate. However it can make a phone vibrate, lazy lazy Unity...
Implementing XInput was easy, only download a package and import it, the only irritating thing is that visual studio doesn't realize that it's in. It gives away errors but unity can still compile and run it like a charm.

To set vibration on a controller I simply have to write: "GamePad.SetVibration(controllerIndex, leftVibration, rightVibration);"

I started with vibration for the Pumping feature, a small vibration when you pump in downhills and a large staggering vibration in uphills, sortof like a coughing engine. This is to make the player feel staggered when pumping in uphills to make them stop, since this makes them lose speed.
I then added a vibration for when the checkpoint boost is fully charged to tell the player to let go, and a small vibration for when the player picks up a small bost, to emphasize the speed increase.
The last vibration I added was for landings, When the player loses alot of speed in its laning I vibrate the controller roughly.

Small things

I created a button that you can spam when you have low speed to gain some speed, I'm not quite sure why we have this, since the problem we had that led to the creation of this button is that "people doesn't respawn at checkpoints when they lose speed". I guese it is to allow the people that don't want to get a good score and only want to cruise to do so.

Petter had made a script that gave objects with a specific tag a rigidbody when you hit them, to make things "destructible", but they didn't reset when you went back to a checkpoint and since I made the respawn system were we reset all the boosts, sparks and so on, I also made the physics objects respawn.
All I did was to make the "PhysObjects" register themselfs in the respawn controller with their position and rotation when they got activated, when you respawn at a checkpoint the respawn controller then removes the rigidbody and places them back at their original position with their original rotation.



I linked the multiplayer lobby Petter translated form my code to the actual gameplaye scene.
To load a different scene in unity you have to change the level prefix of the network, this is just a simple digit that reprisents a level. This is so that the network can filter out any information sent from another level, in adition to that you can also force the network to stop sending information while loading a scene to save bandwidth.




I also created some small scripts not really worth talking that much about, such as a patroling script for some ships that we will have flying over the world.

That's all for today, goodnight and thanks for reading.
-David Forssell

Inga kommentarer:

Skicka en kommentar