Saturday, September 20, 2014

Prototype - Getting Player to Jump in Unity

This week we showed an early prototype of the basic mechanics of our game. This involved getting player movement going and adding tags to the past and present game elements so the player can switch between the two environments with the push of a button.

One challenge we had was getting the player to jump appropriately. As a placeholder, in our player movement script we started with this code for jumping:


    public class moveExample : MonoBehavior {
        ...
        public float moveJump = 0.5f;
        ...
        void Update()
        {
            ...
            if(Input.GetKeyDown (KeyCode.W)){
                transform.Translate (0,moveJump,0);
            }
        }
    }

This kind of worked, but there are several problems with it.


  1. You can keep pressing the jump key, and do some weird looking midair jumps.
  2. When jumping, the player would actually disappear from the ground, and reappear in a new location higher up.
So for the first issue, I added the following code to make it so the player could only jump while on contact with the ground:


    public class moveExample : MonoBehavior {
        ...
        public float isGrounded = false;
        ...
        void Update()
        {
            ...
            if(Input.GetKeyDown (KeyCode.W) && isGrounded == true){
                transform.Translate (0,moveJump,0);
            }
        }

        void OnCollisionStay2D(Collision2D collision)
        {
            if(collision.gameObject.tag == "Ground"){
                isGrounded = true;
            }
        }

        void OnCollisionExit2D(Collision2D collision)
        {
            if(collision.gameObject.tag == "Ground"){
                isGrounded = false;
            }
        }
    }


I also added a "Ground" tag in Unity and added that tag to the different objects that the player could land on.

For the second issue, what I really needed to do was add a force to the player instead of changing its physical location, which looked something like this:


    public class moveExample : MonoBehavior {
        ...
        public float moveJump = 200f;
        ...
        void Update()
        {
            ...
            if(Input.GetKeyDown (KeyCode.W) && isGrounded == true){
                rigidbody2D.AddForce (transform.up * moveJump);
            }
        }
    }

Just like that, our player now jumps, and can easily be adjusted as desired with some physics tweaks.

Thursday, September 4, 2014

Pitch Week!

This week was all about coming up with game ideas and pitching them. To start off, we came up with 15 game ideas and pitched them to several different people speed dating style. After getting that initial feedback we narrowed it down to one.

Then we pitched our ideas to a group of 12, and voted on the top 2 to 3 game ideas that would move on to the next round.

So far my game idea has survived, but it has yet to see the most brutal round of criticism and feasibility analysis. So what is this game idea?


Introducing....

TIMEY!

Timey is a cute little blob character that finds himself in a dark, mysterious world. He quickly finds out that he can instantly travel between two or three time periods, and when he thinks about time, the name Timey sounds sort of familiar to him so he decides that must be his name. He'll need to use his ability of instant time travel to work through his environment when he gets stuck, and some of the things he does in the past can have an affect on his future environment, like planting a tree or setting some termites loose. As he moves on he develops and gains new abilities, and discovers clues about what is going on.

The environment Timey finds himself in is a result of a bad person of course, who decided to destroy the universe by creating a paradox. To do this, the bad person found a way to travel back in time and kill a little kid that would have had a long productive life. Instead of destroying the universe though, Timey was formed and now has to figure out how to repair the damage before the universe disappears, or explodes, or otherwise has a bad experience.


I think his biggest challenge will be to survive the final game cuts as there are a lot of great game ideas still left out there, and only 4 or 5 will actually be worked on.