Posts

Showing posts with the label c#

Unity3D events, delegates and Action

Image
Delegates and events are very powerful features of C#. With them you can write clean and efficient code also in Unity. However, I have found delegates bit confusing to understand. Most of the examples I have seen are not so easy to understand, especially if you are a self-taught coder like me. :) Most of the examples I have found are using both delegate and event definitions. Something like this: public delegate void PlayerHit(int damage);  public event PlayerHit onPlayerHit;  But personally, I like using Action<> type instead. It allows you to replace two lines with one and it will make your C# code simpler. It also removes some confusing buzz around delegate definition. Here's an example: public static event Action<int> PlayerHit; So, at least for me this looks more understandable. Please find below two very simple code snippets from my GitHub repository  to see a real life example using Action in defining delegate. In this example event passe...

Re-usable Unity3D scripts at GitHub!

Image
During last couple of years we have created some generic Unity3D C# scripts. These scripts have been design to be re-used at least to some extent, to ease up new game project creation. Now some of them are available for public at GitHub: https://github.com/jliias/CommonUnityScripts We have selected the ones that we think are most readable and understandable and also well (?) commented. New general purpose scripts will be added when there is something we think is worth publishing. Please have a look and see if there's something useful also for you! -Jussi

Going hyper-casual (or die trying)

Image
For some reason, hyper-casual games seem to be one of the hottest thing in mobile gaming at the moment. Just do some googling and you will notice that they really are trending. This weekend my target was to do fast-paced game development, starting from a concept and resulting to a published game. And goal was achieved, even though there is still lot of room for improvement. Anyways, my coding skills got some practical exercise, what was the purpose of this project. "Rocket to Uranus" is so-called hyper-casual game for Android. It is available at Google Play Store .   Some statistics: - Total of 15 hours of time (3 evenings) - Approx. 400 lines of new C# code written + ~100 lines of re-used code - 10+ art assets drawn with Inkscape - 2 Unity scenes created - Lots of testing, debugging and bug fixing -Jussi

Unity3D: Camera Shake Effect with C# Example

One of my unfinished Unity3D game projects required camera shaking function, so I wrote one from scratch. I just needed a script that shakes camera for a certain time and magnitude, and can be called from other script. Also, sometimes it would be useful to trigger this from UI button using OnClick(). Added 9.10.2018: This script is now available also at GitHub: https://github.com/jliias/CommonUnityScripts/blob/master/CameraScripts/ShakeCamera.cs Please find script below: Script is added as a script component to the Camera type object and then it should be ready for use. You just have to figure out how and when to trigger it in your own game. I hope that someone will find this script snippet useful! -Jussi

New project: "Bananamarine"

Image
Hi for a long time! Despite the silence WestSloth Games is alive and kickin'. :) I have been working on our next title for couple months, and now it seems that full release can be done within couple of weeks. The name of the game is Bananamarine and currently we have plan to publish it only for Android devices. This will be our first game developed with Unity3D and C#. Player will control small yellow submarine called "Bananamarine". There will be pearls to be collected and mines to be dodged. Also, a mixed selection of very special marine organisms are swimming in this game. If interested, please check attached video from Bananamarine playtest. Basic functionality is working pretty fine and some features are still to be added. All graphics is drawn by me (unfortunately), so please don't mind so-called "coder-art". :) That's all from us at the moment. Be prepared for full launch within June 2017! -Jussi