Unity touch input

My first encounter with Unity touch input didn’t go as I wanted it to.. After some failed attempt and a test scene in Unity, it did started to make sense. And finding out that touch has phases and FingerId’s helped a lot. 😉 So here’s my take on a controller and firing script for my current project.

private shieldFingerId = -1;

...
// If nothing is touched, the shield controller has been released
// Know I should test for the shieldFingerId to be released, but this works for my purpose.
if (Input.touchCount == 0)
{
	shieldFingerId = -1;
}

foreach (Touch touch in Input.touches)
{
	// Fire
	if(touch.phase == TouchPhase.Began && !withinShieldController)
	{
		Fire();
	}

	// "Grap" shield
	if (touch.phase == TouchPhase.Began && withinShieldController)
	{
		shieldFingerId = touch.fingerId;
		UpdateSheldAngle(touch.position);
	}

	// Move shield
	if (touch.phase == TouchPhase.Moved && touch.fingerId == shieldFingerId)
	{
		UpdateSheldAngle(touch.position);
	}
}

As you can see, when I got hold of the information about touch.phase and .fingerId, everything turned out to be very simple indeed.

I found the Unity Script Reference pages to be very limited on the subject of touch input, e.g. information about touch.fingerId only says “The unique index for touch.” no examples, or explanation. But by asking Google, and searching the Unity forums, great resource I might add, it finally made sense. 🙂

Working with touch has forced me to use my LG E975 mobile for testing, which is a slow process. :/ I guess I have to figure out how to make Unity Remote work with my phone. If not, development is going to take forever!

Hope the above code makes sense? Now go make games! 🙂

– Henning

Gastorid, lacking layers.

After testing Gastorid again and again, I don’t find it have the lasting gameplay I’m looking for. A change in game objective might help? But for now I can’t figure out what to change. :/
Below you can see at short play through of the game as it is for now.

I don’t think that making specific levels design/setups, will add to the gameplay (for now it’s just random). Something more is needed. I might get some ideas in time, and try to add them.

Even though I hate abandoning a project, for a while, i hope that working on other things, will give me some new inspirations. If not, I will have learned a lot, I can use in my next project.

Working with touch devices is something completely different than making mouse/keyboard controlled games. The biggest challenge I have found is that I will cover a large section of the screen when clicking on the left part of the screen (I’m right handed). So some simple game ideas just won’t work, or the controls has to be redesigned… Just writhing the lase section gave me an idea that I have to test. 🙂

Got to go and the a new control for another prototype that I’m working on.

Have fun, and go make game!

– Henning

Gastorid mobile shader.

Ok, so I’ve had some time to work on my idea and I finally gotten it to work on my mobile phone. I’ve been stuck for hours and hours trying to get my game to work on my phone. Every time I switched the mobile shader for my linerenderer, to the one I wanted, the game simply stopped when initializing an object using that shader?? What the …! After adjusting just about everything in the unity editor, I finally stumped upon Edit->Project Settings -> Graphics, where there’s an option called “Always included Shaders”. Looked like this could be the problem/solution. After adding my custom shader to the list, everything worked 🙂

Always Include Shaders

Always Include Shaders

Not something I will ever forget to do ever, ever, ever again.. 😉 So now everything works, and the game is really starting to take shape. The audio is still horrible, and the gameplay needs some adjustment, whats to add time bonus/limits, but I really like what the game is morphing into.

Gastorid Screenshot Menu

Gastorid Screenshot Gameplay

I have only one android device, so I’m looking forward to having friends test it on their devices, to see if there are problems with the different resolutions and aspect ratios. Which has really given me a lot of headaches, and maybe for nothing.. It have been a lot easier to work with, now that I’ve started using rich text in all my GUI text. It all looks good in unity, but you never know what might pop up on strange devices 🙂

Now go make games! 😉

– Henning

KISS.. Keep It Simple, Stupid. New project, Gastorid.

Ok, the zombie game was a bit of a mouthful, and I know that if I’m to do it as I would like to do it, it would take me years. 🙁 So again I have ignored the second rule of getting into indie game design, keep it simple, and aim even lower (first rule is “Go make a game!”). I shot high and learned a lot, but will never be able to finish the game, even though a work mate finds great enjoyment shooting the zombies just to see the ragdoll effect. 🙂 It does look kind of funny. 🙂 But still I have dropped the FPZS. :/

But then what? Well I have been wanting to make a small game for mobile/tablet for some time, but have been stopped by the many different resolutions and aspect ratios of the screens. But it simply can’t be as bad as I think it is? Or can it?

Gastorid Idea

Gastorid Idea

By accident I came up with a small game when I was testing some simple gravity simulation on my phone, and after a few iteration on the game mechanics I think I have a game, if only I can make the click/finger down a lot more precise as the objects on the screen are fast and small. I have an idea in mind I want to test later, it’s casting a ray and test to see which object is closest to it and then if its within some radius, I’ll accept it as a hit.

Well a lot to do, so, less writing and more coding.. 😀

– Henning

Zombie Game

As everybody else, I have at least one friend wanting yet another zombie game. So I’ve started making some initial tests for a small fpZs. It is inspired by the prison from the walking dead. So as I see it now (will change over time, as always) I’m going to place the player in the middle of the compound with a rifle, and make zombies storm the compound from all sides. You have to dispose of them before they overrun the inner part of the compound.

This will be the first time I work with 3d charater models, ragdoll and animator. which from time to time have resulted in some very funny and fustrating bugs. One bug that took days, was the ragdolls fell to the ground as expected, then about 5 secounds later they would, for no reason, jump into the air. This would repeate with increased force each time. It turned out to be a collider and rigdiget body element I had added, before adding the ragdoll to my charater. I removed the collider and rigdigetbody, and everything worked fine.

Adding the animator was a challenge, but after watching “Unity 4.0 – Mecanim Animation Tutorial” from Unity3D, which gave me a good introduction into the workflow of mecanim. I was able, in less than an hour, to set up a 3d model and make it run on the spot, but non the less, run. 🙂

Stopping the animator and making the model go into ragdoll mode should be easy. Stop the Animation, set all the elements IsKinematic to false and let the physics engine take over. But again something weird happened, when I shot the zombie the animation stopped and the character started to fly around i big circles. Very weird, but kind of funny looking. It turned out that I disabled the animator, stopped it, and then set IsKinematis to false each frame. which did something strange to the physics engine.

I know I have to start over on the model and the ragdoll setup, to make everything match up a lot better. As I didn’t make the model I got a bit confused about what was shoulder and what was forearm, so the ragdoll feels a bit weird, but it works.

Next I’ll be working on the movement of the zombie, to make them move from A to B avoiding the other zombies. I plan to base the algorithm on the work of Stephen. J. Guy, Jatin Chhugani, Changkyu Kim, Nadathur Satish, Ming C. Lin, Dinesh Manocha, and Pradeep Dubey in their 2009 paper, ClearPath: Highly Parallel Collision Avoidance for Multi-Agent Simulation. They made this video to explain the algorithm and to show it in action.

Visit their page where you can find the video and their paper on the subject. http://gamma.cs.unc.edu/CA/

First of all I’ll of cause try to do it all only using Unity physics using basic colliders, to see if the above algorithm will be needed at all.

Until next time, keep making

– Henning

3×3 final version

Ok, I now regard the 3×3 game as finished. I know I could spend more time polishing is, with better graphics, sound and more depth. But, the entire project started as a POC and was never meant to become a playable game, so now that it’s playable and people enjoy playing it, I’ll move on to the next game.

The progress of the development of 3×3.

Hope you’ll enjoy it too. 3×3 Final version. 🙂

– Henning

3×3 version 10

After feedback from a few testers, thanks to them all, I have made some changes to the game.

  • I have opened the sides of the tunnel and added some stars to get away from the very claustrophobic feel.
  • I added a single power up in form of the ability to remove an entire wall. The power ups spawn every 10 to 20 seconds and they stack.
  • The biggest change is the textures of the boxes. I really spend a lot of time trying different textures, shapes and colors, still I’m not 100% satisfied, but I think it’s better than before.

If anyone would like to do some textures for the game, feel free to contact me, I’m sure you could do better than what I ended up with 🙂

3x3 ver. 10 Unity Screenshot

One thing suggested that I would have liked to include, was an idea to have the tunnel twist and turn. But as this was never the intention, the code would have to be rewritten from the ground up. So this will, if ever, have to wait to future project.

Play version 10. Enjoy and please send feedback.

– Henning

3×3 Version 8 – Now in Beta

Version 8 of 3×3 ready, or should I say Beta version! 🙂

3x3 version 8

3×3 version 8

I have used the last days to add a lot of small things to the game, tweaking it, and playing it, again and again. I also had a friend play it, a lot, to see if I missed something obvious.

Here’s a list of what I have done.

  • Added particle effect for the box explosions.
  • Updated sound effects.
  • Added Gui Skin
  • Added Font
  • Changed resolution to 1024×768.
  • Player control, motion can now be changed in mid move.
  • Collider made smaller for when player is rotating.
  • Added Crash SFX
  • Updated Move class to separate horizontal and vertical movement to allow diagonal movement.
  • Added 10000/15000/20000 points SFX
  • Added level 10/15/20 SFX
  • Added Audiosource mini buffer to hold 4 audio sources.
  • Adjusted colors of boxes to make them easier to distinguish.
  • Added plane to slowly revile the boxes, and not just pop into existence in the back of the scene.
  • Updated all level and point SFX.
  • Adjusted music slowdown to 0.75 instead of 0.5 when dead.
  • Changed font to Plasmatica by Apostrophic Labs.
  • Adjusted GUI boxes to match the new font

The best update, is the ability to move freely, and in all directions. I thought this would be a pain to make work as I wanted, but with a few changes to the already existing moving class, and the separation of horizontal and vertical movement, it was surprisingly easy. 🙂

One thing I didn’t expect to give me any problems was the colors of the boxes, but as I tried to make the colors easier  to distinguish from each other, the bigger problems I got with the lighting settings. First the scene was overlit when the boxes came close to the spot close to the player,  then under lit. Then the ambient light made everything look flat, and so on. So I ended up spending almost 3 hours adjusting colors and light settings. But I’m finally happy with the result.

After I added more sound effects I found that they would cut off each other, so I added a mini buffer, to hold 4 audio sources and use the first available. This gave a hole new, and more complete feel, to the game.

3x3 version 8 Menu

3×3 version 8 Menu

Hope you enjoy the game 🙂 And have time to send me some feedback.

– Henning

3×3 Version 7

Finally I’ve had some time to work on the 3×3 project, which have resulted in a version 7.

3x3 version 7

3×3 version 7

I’ve added a particle effect with box meshes, for when boxes are removed. I’m using the color of the removed box to fake the box exploding/being torn apart.
I had some difficulty getting the particle effect to use color over lifetime after switching to box mesh. So I ended up making a small fadeout script.

    public float alphaStart = 1.0f;
    public float alphaEnd = 0.0f;
    public float overTime = 1.0f;
    private float alpha;
    private float deltaAlpha;

	// Use this for initialization
	void Start () {
          alpha = alphaStart;
          deltaAlpha = (alphaEnd - alphaStart) / overTime;
	}

	// Update is called once per frame
	void Update () {
          alpha += deltaAlpha*Time.deltaTime;
          Color c = transform.renderer.material.color;
          c.a = alpha;
          transform.renderer.material.color = c;
	}

It’s linear, which I didn’t really want, but for now its ok. I plan to make it a bit more controllable. Something like time to wait before starting to fade out.

By pure accident I discovered that I hadn’t used Time.deltaTime anywhere, so I have corrected this, and tested and set new speed values in all scripts, moving, rotating or scaling objects over time.

After playing the game a few times I noticed that I wasn’t getting any points after level 8. This small bug was of cause, also fixed.

I plan to add some more sound effects and get some basic menus set up over the next few days, but I ‘ll have to see what time and motivation life brings. 🙂

Play version 7 and remember to give feedback. Thanks 🙂

– Henning

 

Don’t Fall Asheep NO Progress 2013-06-10

I’ve heard that. if you don’t like doing something, then don’t do it 🙂 I found that working on the Don’t Fall Asheep project didn’t give me the joy I expected, so I’ll put further development on hold, for now, and focus on the 3×3 game which I really enjoy doing. 🙂

In time I’ll take a new look at it to see if the idea has sparked some new creative energies. But for now the game is dead.

– Henning