Pigeon shit

[ Pigeon shit ] Unity data persistence – serialization

After looking at the found options I decided to go with serialization and if feasible google play services. This because serialization basically supports everything and is easy to implement. You just have to make sure all the data that you want to save has the serialize tag like so:

public class GameData { 
//all data goes here

And then you can save the data with a function like this:

using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

public void Save(GameData data){
   BinaryFormatter bf = new BinaryFormatter();
   FileStream file = File.Create(Application.persistentDataPath + “/gamedata.gd”);
   bf.Serialize(file, data);

Pigeon shit

[ Pigeon shit ] Unity data persistence

Hello there, been a while..
I have been working on the data persistence of the game, the choice was made to do local storage and if feasible online storage (in the cloud~). After a short research I had found the following possiblities:

The most easy and standard used solution. Playerpres supports:

get/set floats
get/set ints (booleans are possible if you convert them to integers ea 0-1).
get/set strings

– Writing / reading  XML / JSON formats
I don’t think I’ll pick this one, the format is very human readable and players could mess with it to cheat.

With this we can write and read whole classes with nested classes etc in them and is safer than XML/JSON because it’s less readable. Serialization supports:

custom non abstract classes with [Serializable] attribute.
custom structs with [Serializable] attribute. (Added in Unity 4.5)
references to objects that derive from UnityEngine.Object
primitive data types (int, float, double, bool, string, etc.)
array of a fieldtype we can serialize
List<T> of a fieldtype we can serialize

Google play games services API
this can be used to do the online-cloud storage of our game data so the players data is linked with their play store account and his/her progress is linked on multiple devices.
Have to look more into this in the future when we integrate google play.

Pigeon shit

[ Pigeon shit ] Unity UI fading part 2

ScreenHunter_49 Oct. 26 18.43


This evening I made the Game over screen, and here I also wanted to have a fade in/out of the screen. Earlier with the playerscore in the HUD I used crossfade but calling that for each and every object on my gameover screen just feels weird and I knew there had to be a better solution. So after looking around the net I found out about the Canvasgroup component. When you add the component to a gameobject and child every canvas object to it, you can adjust the alpha value on the Canvasgroup component and it will automatically adjust all alphas of each and every child! nice. Exactly what I was looking for. After that I made a little script called CanvasFade and used Coroutines to do the fading(adjusting of the alpha over time).

Pigeon shit

[ Pigeon shit ] Unity UI fading part 1

Fixed the issue with the player HUD still being visible after camera fade to black. What I did was take the canvas component and fade it separately with the same fade time as the camera using the function CrossFadeAlpha(); However on the unity editor play you would see a little bug whereas the left side of the screen would still be visible but luckily after running it on my mobile device that was not the case. This however need more testing on other devices to see if we need to fix it.

Pigeon shit

[ Pigeon shit ] Unity doesn’t like lerping an moving object

PigeonShit_ThumbSmall So I was working on the controls on the player object (the pigeon shit that’s falling down). We made the decision to disable gravity and handle all physics through code. Why we chose this was because we wanted to have total control over the object so that it does exactly what we want it to do. This way without a rigid-body we don’t have to work with applying force to move it forward/side wards with which you don’t know where it will end up exactly. However a problem that came with this decision was that unity doesn’t like it when you do a linear interpolation(lerp) on a moving object.

(problem) The idea was that the pigeon shit is falling down, so the object has to move down on the y-axis(vertical) constantly, this is a transform. Meanwhile the pigeon shit will have influence from  player-input and the game itself. This happens on the x-axis (horizontal) and is a lerp . So what happened is that when you’re moving the object down and do a sideways lerp it would do the lerp and stop falling down (meanwhile in code the y-position is still going down), when finished with the lerp it would teleport to the in code y-position and continue falling down. This looks very weird and is thus unusable.

(chosen solution) what I did to solve this was to separate the transform from the lerp by making a empty game-object on which you apply the sideways lerp on and where the player-object listens to and copies the x-axis from. The result is a very smooth lerp while falling down :)

Looking back at it of course it wouldn’t have worked. A linear interpolation is finding a value that is some % between value A and B, and in out game it is used to move an object from A to B in a given time-frame. What is important is that the point to which he has to move to is set at the lerp start. Meanwhile the player object is moving down and thus the position changes and the lerp-to position is not correct anymore. What I could have done was to update the lerp-to position on every game update but whether that works is something for another time.


Pigeon shit

[ Pigeon shit ] unity Text Color problems

ScreenHunter_38 Oct. 13 12.59

So I was working on Pigeon shit as usual and added a neat little FPS counter for debugging that displays the fps on a Text component. The text would change color (red, yellow, green) depending on the fps. To do this I used text.material.Color, however this would turn all my text components in the scene to green! And had to restart unity to fix it =S found out you had to use text.Color haha, makes sense if you think about it :). I think all text components uses the same material so yeah if you change the color on that material ofcourse every Text component would change color :o

Pigeon shit

Pigeon shit, a game by WannabeStudios

2015-10-06 10.27.32The idea behind pigeon shit is that of a casual game that you can play in between stuff. Think of games like flappy bird, Run bird run and Jelly jump. With this as core it was decided that the controls had to be simple: 1 tap, maybe 2 taps at a time max needed to control the whole game. The goal of the game itself is to dodge obstacles and to get your shit as far as possible. As it stands now we planned a endless mode and a story mode. The story mode exists of predefined levels where you dodge obstacles and land your shit on someones head for bonus points. In the endless mode however we are focusing more on getting as far as possible, and thus aiming to get further with every try.


Pigeon shit

I’ve got an idea..!

Recently got an idea for a new game while showering =d I named it “pigeon shit” for now. Basically you’re a pigeon and you take a shit… simple no? All you have to do as player: help the falling poop evade all the obstacles that can stop it from reaching it’s destination: someone’s head. Awesome. 10/10 would play.

Jokes aside, talked with a fellow programmer about it and we’re going to work it out in more detail and make an awesome game out of it. The end goal would be to get it on the playstore since we wanted to get some experience in that field (publishing/releasing an actual game on the playstore).