Game Design 2 - Bounce Mechanic

My experience while working on a bounce mechanic for our game made with Unity.

Written the by Thomas Cairns.

Introduction

During the period of ten weeks, between week 3 and including week 12 I'm attending the course Game Design 2: Game Development. The course is hosted by Uppsala University with Marcus Ingvarsson as the course director.

As part of the course I'm creating a game together with four other students, we form team Leviathan. The course is broken up into three parts, two weeks of pre-production, five weeks of production and three weeks of post-production.

There are a few restriction on the development of the game that will shape some of the decisions we make so let list them before we continue.

Concept

We choose to work on the concept called Draxl's Journey created by team Kraken. The concept is label as a casual space-shooter. Where the core mechanic revolves around the idea that the player doesn't have any offensive weapons, but rather a shield to deflect projectiles back towards the enemies.

Bounce

As one of the programmers on the team, one of my tasks for first week was to work on the projectile reflection. In other words how the projectiles travel pattern should behave on collision with another object, we call this the bounce behaviour. While working on this behaviour I have come across two possible solutions.

Unity Material

The first idea I tried was to use Unity's bounce material that we have been introduced during a lecture. The bounce material works using Unity's physics engine that utilise the properties of gravitation, mass, linear drag and rotational drag. Then the material itself also introduces two properties, friction and bounciness. These are a lot of variables and I'm not sure how all properties interact with each other and it doesn't seem to be all that obvious based on forum posts/question I have found so far.

Projectile bounce with Unity material with friction

Example of how a projectile behaves when using Unity's bounce material with one value in friction. The image only illustrates collision with a flat surface.

With that said the bounce material works fairly well, there are only two problems so far when using it for the bounce mechanic. The first problem is that velocity can be transferred between objects that collide, what this means is that projectiles can have varying travel speed over time even if they started out the same. The second reason is that when using zero friction the material has a perfect reflection but the side effect is that if the trajectory angle goes below a certain degree the object will not actually reflect but instead sliding against the surface it collides with.

Projectile bounce with Unity material with zero friction

Example of how a projectile behaves when using Unity's bounce material with zero friction. The image only illustrates collision with a flat surface.

The combination of the two behaviours makes it difficult for the player to predict and calculate projectile bounces in advance. Since game is supposed to be a bit more light hearted and within the realm of causal play we don't think this would be optimal.

Own Calculations

In order to test against and have something that works more like what we want I spent some time creating a script that does perfect reflection of an objects velocity. It always rotates the object so it's facing it's travel direction. The experience becomes more like the fake physics one would expect but since the approach is naive and doesn't handle the velocity of the object it collides with and other details which results in some very strange travel paths.

bounce-reflection.png

Example of how a projectile behaves when using our own script. The image only illustrates collision with flat surface.

We are using this approach right now in order to test it properly, in the future we'll see which one we actually go with. Since this one would probably require quit some polish.