Big Spiky Death Balls – Project Spikes 27/09 Update

I’ve finished the fourth level and improved the existing three slightly with features from this update. Firstly, I’ve added large spike balls. They’re rather deadly and tend to fall on your head.

spikes-15They were pretty fun to experiment with with positioning, along with Unity’s physic materials (especially the bouncy one) to make them hop around the stage like kangaroos on meth. I also added mini posters/ billboards that warn the player of dangers ahead, and one at the start of each level to tell you the level number.

spikes-16

If you wondered what the player looks like in my scene view, he’s a bright purple capsule. He’s a little bit feminine and proud of it.

I’ve used some existing objects to devise new traps for the player – you’ll have to find them for yourself though! Along with this comes a new health bar, which is much more colourful (and hence, better) than before; it’s a nicer way of displaying remaining lives and health. There’s a few new features such as a start screen and pause screen; the latter of the two is accessed through the escape key. The cursor stays frozen in the centre of the screen and hidden while the game in unpaused, meaning it won’t stray from the game window and interfere with other applications.

spikes-17Also, as some players pointed out, some moving platforms used to stutter when stood on, but this has been fixed now by updating their position in the FixedUpdate() function rather than Update(), as the former is ran before the latter. Turrets have also been improved, as their bullets get destroyed after coming into contact with any collider, not just the player, and they aim better.

CHANGELIST / TR;DR
-Added large spiky balls of death and physic materials
-Added a fourth level
-Added small warning posters
-New trap variants
-New health bar
-New start menu
-New pause menu -  press "esc"
-Fixed bullets only being destroyed after hitting player and turrets' aiming
-Fixed stuttering platforms

For next update, I will be finishing up World 1 and perhaps starting work on World 2. The fifth and final level in this world will be a bit bigger than the previous ones, and feature a puzzle in order to advance forward. So far, it looks promising.

If you want to try the game out, the link is the same as it always has been: play it here! And thanks for playing!

People Like Grapes: Project Spikes 21/09 Update

It’s been a week since the last update, and I’ve gotten some feedback on some issues in the game, which I’ve been trying to fix, along with adding new stuff. I present to you the latest update, playable here!

spikes-12

Behold my modelling skills!

I’ve added bunches of grapes around some levels, which restore 50 health to the player. It’s a pretty basic model, which will likely be improved in time. Along with this I’ve added a new type of moving platform, one that stops temporarily after it has moved, before moving again (some have spikes on too. Super hardcore mode activated!), and transparent platforms which are a little harder to navigate.

spikes-13Along with this, there are billboards at the start of some levels that show the user useful information such as controls through use of little pixellated pictures, to aid the player get used to the game. The health counter in the corner has been replaced with a health bar that is centered in the middle of the screen below the lives bar, and also re-sizes itself when the health changes.

I have also added turrets, which take aim at the player if they are in range and fire bullets at them, which in turn damages them.

spikes-14They do need a bit of work done on them to make them a bit better, which will hopefully done in an upcoming update. I’ve also added crouching so that the player can reach into spaces they couldn’t before –  this will be vital in level 3.

This time around there are only three levels, but I’ve made them a bit longer (and hopefully more interesting too), so give it a try, and leave a comment if you have any improvements or bugs you’ve found!

CHANGELOG / TL;DR

Added:
-Grapes, which restore health
-New platforms that have a delay after moving
-Transparent platforms
-Turrets, which shoot bullets at the player
-Billboards to display information
-Health bar
-Crouching

Changed / fixed:
-Levels changed again -  longer, more features
-Spikes now damage the player every half-second while still stood in them

Random Code: Player Crouching

Unity includes prefabs for 1st- and 3rd-person characters, but they lack some basic movement features such as sprinting and crouching, which I find to be a little bit stupid, so I’ve written code to do this for me. It’s simple really – it starts by finding the character controller component attached to the player, then gets his (or her, equality fans) height, then when the player is holding the ‘c’ key, it scales down the character controller height so your player can squeeze into tiny gaps –  just attach a script with this code in it to your player and it should work. So, just for you, here is my code for crouching!

private var controller: CharacterController;
private var charHeight: float;

function Start()
{
    charController = GetComponent(CharacterController);
    charHeight = controller.height;
}

function Update()
{
    var height = charHeight;

    if(Input.GetKey("c"))
    {
        height = charHeight / 2;
    }

    var lastHeight = controller.height;
    controller.height = Mathf.Lerp(controller.height, height, 5 * Time.deltaTime);
    transform.position.y += (charController.height - lastHeight) / 2;
}

How it works!

Firstly, the variable controller stores the character controller, then charHeight stores a float. In the start function, it finds the controller attached to the player and defines charHeight as the controller’s height as a reference point. Then in the update function, it takes the height at the start of each frame, then if the ‘c’ key is held down, it basically halves the height (smoothing it by using Mathf.Lerp, which takes the first parameter given to it and changes it to the second parameter over time, changing by the third parameter each frame, so basically in this case it takes the normal character height and changes it to half that by 5 units each second, through use of Time.deltaTime to ensure the change is framerate-independent. If that all made sense.) and moves the whole transform down in the y-direction by half the change in height, to match the change in the controller’s height. The net change is that, when the “c” key is held down, the player, along with the colliders and camera attached to him/her, crouches down. Feel free to use this code in your own projects, and if you have any improvements, you can post a comment here. Have fun crouching, and if none of my explanation made sense, just post a comment and I’ll get back to you 🙂