Bloodirony Blog


Blog

INSIGHTS, TUTORIALS AND DIRTY SECRETS

Viewing entries tagged
indiegamdev

The Art of Screenshake in Unity2D

Comment

The Art of Screenshake in Unity2D

Due to the fact that our Big Bad Bearded Boss is a huge Vlambeer fan, my first task was to watch the presentation of Vlambeers Jan Willem Nijman Gamefeel. JW showed 30 little tricks to make your action game more fun. This post is about how to implement some of this tricks in Unity for our upcoming game Shooting Stars.

Screenshake

Let's start with the screenshake effect. The main approach is to shake the camera randomly in special moments of the game. For example on a bullet impact or an explosion. My first attempt to get this done was using iTweens ShakePosition(). The effect itself was really cool, BUT there was a problem with multiple screenshakes at the same time using ShakePosition(), so I started to implement my own solution:

private Vector3 cameraStartPosition;
private float shakeAmountX;
private float shakeAmountY;
private float time;
bool reset=true;

public void Init () {
    cameraStartPosition=Camera.main.gameObject.transform.position;
    InvokeRepeating("CameraShake", 0, .01f);
}

public void ScreenShake(float amountX, float amountY, float _time){
    if(amountX>shakeAmountX){
        shakeAmountX = amountX;
    }

    if(amountY>shakeAmountY){
        shakeAmountY = amountY;
    }
    if(_time>time){
        time=_time;
    }
    reset=false;    
}

public void ScreenShake(float amount, float _time){
    if(amount>shakeAmountX && amount>shakeAmountY){
        shakeAmountX = amount;
        shakeAmountY = amount;
    }
    if(_time>time){
        time=_time;
    }
    reset=false;
}

void CameraShake(){
    if(shakeAmountX>0 && shakeAmountY>0 && time>0) {
        time-=.01f;
        float quakeAmtX = UnityEngine.Random.value*Mathf.Sin( shakeAmountX)*2 - shakeAmountX;
        float quakeAmtY = UnityEngine.Random.value*Mathf.Sin(shakeAmountY)*2 - shakeAmountY;
        Vector3 pp = cameraStartPosition;
        pp.y+= quakeAmtY; // can also add to x and/or z
        pp.x+= quakeAmtX;
        Camera.main.transform.position = pp;
    }else if(!reset){
        Camera.main.transform.position=cameraStartPosition;
        reset=true;
    }
}

Kickback on Shoot

Another thing I wanted to implement is a little kickback whenever our main character is shooting lazers, bullets or whatever. Due to the fact that our game is a vertical shootemup this was quite easy to implement. Whenever our main character is shooting I manipulate his y position by a small random amount:

targetPosition.y=targetPosition.y-UnityEngine.Random.Range (0.1f, 0.3f);

Permanence

I also thought about implementing some permanence. So I decided to make our “lazer shells” permanent. First of all I created a flight path for our shells by using iTweens MoveTo(). Not really satisfied with the result I added some rotation to the shells by using RotateBy(). After the movement of our shells is over the GameObjects will stay whereever they moved to. The problem is, that after some minutes of constantly shooting, you have a lot of shells lying around. This is not a problem for the PC or Mac version, but will be a problem for mobile devices due to limited amount of available Memory. So for performance reasons I have to destroy the shells (or move them back to a pool) after some time.

float height=UnityEngine.Random.Range (0.2f, 0.7f);
iTween.MoveTo(gameObject, iTween.Hash("path",new Vector3[]{
    new Vector3(transform.position.x+0.4f,transform.position.y+height,0), 
new Vector3(transform.position.x+height+0.2f,transform.position.y-0.4f,0)}, "time",1,"easetype",iTween.EaseType.linear));
iTween.RotateBy(gameObject, iTween.Hash(
    "name", "ShellRotation", "looptype",iTween.LoopType.none, "z", Random.Range(-6f, 6f), "time",  0.9f));
Destroy (gameObject, 10f);

What's next?

Because of problems with permanence, missing image effects, etc. we consider switching from the free version to Unity Pro. Come back soon, if you want to know which way we will go.

Comment

What the heck is indie? #CEGC15

1 Comment

What the heck is indie? #CEGC15

Last week we've spent two days at the first Central European Games Conference 2015, at the University of Applied Sciences Technikum Wien. And to keep it as short and simple at possible: we've greatly enjoyed being there. We've especially enjoyed the high quality of speakers, interesting (and mostly bearded) attendees, the overall organization and of course the afterparties. #CEGC16 we are coming!

Tscherno photobombs a speakers panel at the Central European Games Conference / Photocredit: www.cegconf.com

Tscherno photobombs a speakers panel at the Central European Games Conference / Photocredit: www.cegconf.com

While we were talking to lots of attendees and showing them our Shooting Stars prototype we had several discussion about our way to develop this game. Not from a tech-related point of view but much more how our game-jam(-ish) approach works and whats the ideology behind all that. There, we realized that the definition of being an indie game developer creating indie games couldn't be more diverse. Especially when everybody claims to be indie. Which (obviously) led us to the question:

What the heck is indie?

If we trust Wikipedia being indie or being an indie game developer means nothing less than:

"Independent video games (commonly referred to as indie games) are video games created by individuals or small teams generally without video game publisher financial support."

So, that basically means: If you decide to make a video game without a publisher you are an indie game developer. End of story!

If we compare a title like This War of Mine with e.g. Binding of Isaac, both being indie games, you're able to see lots of differences like graphics, sound, gameplay, ... but in our case none of those differences matter. Because the thing you can't see is the biggest differentiator: the budget!

So, This War of Mine is kind of an AAA indie game but separating the indie scene into AAA games and "other" games seems pretty useless to us. Because, we believe that having 30+ people on your payroll, and according to 11bit studios Design Director, Michal Drozdowski, 14 people in the core-team just working on This War of Mine, you need a shitload of money to fund this. And to earn this pile of money you need to have investors or a valid and working business (in 11 bit studios case they are just doing a pretty good job creating games). 

And to finally come to my point, I'm going to borrow a definition from the startup-world. 

"A startup company or startup is a company, a partnership or temporary organization designed to search for a repeatable and scalable business model." – Steve Blank

So, if you are able to pay for people other than the usual founders and maybe first employees you've probably left the startup/indie phase and are in a growth phase but much likely it's not a startup anymore – it's a company, a company with a clear and valid business case.

In our case, we have decided to be an indie studio. We want to keep our team small, and work on crazy and funny projects that seem ridiculous. There is no desperate wish to roll in money and to head straight to our IPO. But sure if things happen differently than planned we may leave the indie phase to become a "regular game studio" like 11 bit studios is today.

To sum things up

We believe that being indie is a phase (that you don't necessarily have to leave): 

"An indie game developer or indie studio is a company, a partnership or temporary organization designed to search for a repeatable and scalable business model." – Steve Blank Malzner

Oh and by the way, we actually love what 11 bit studios are doing! Additionally they're creating jobs, (hopefully) pay taxes and of course they create pretty awesome games. So, this article is not supposed to be a rant, they are just a perfect example for the situation we're talking about. 

Feel free to discuss this article with us and don't forget to follow us on Twitter, like us on Facebook and sign up to our Shooting Stars Beta.

1 Comment