Brave Octopus Adventure - the brave octopus is ready to conquer your Android smartphones

    Hello. Not so long ago, I had free time, which suddenly coincided with the time when I wanted to do something of my own, dear.
    And what can an ordinary programmer want to do? Of course the game !
    Under the cut, my little story, which can hardly be called instructive or unusually exciting, but nonetheless ...

    It all started about a week ago. In principle, I had considerable experience in programming in general, and there was practically no experience in the game maker. About a year or two ago, I set myself Unity3Din order to see what kind of animal it is, so the only one I knew was selected from the development tools. Of course, it would have been possible to draw everything on canvas, but, I decided that, perhaps, it’s not worth it. From this initial acquaintance, I still had some memories about gameobjects, components and the fact that you can make an orthographic camera to make a 2D game in Unity3D. As it turned out, in current versions of Unity (starting with 4.3) 2D support appeared “out of the box”, which I was extremely happy about. Now the process of creating a game object is reduced to dragging the sprite onto the scene. The sprite even scales to different screens, though I don’t know whether it does it in width, height or in general in area (or maybe sqrt (area)?).
    Here is a very scary and ugly initial draft of the game screen.

    Yes, it was conceived as a platformer in the style of the prehistoric Impossible Game .
    IT was drawn in a burst of inspiration, when I suddenly decided that I could do everything. A man showed it to a couple, took off his pink glasses and began to think. Because no development budget was allocated, then my 12-year-old sister was determined to be the artist / designer.
    Here is a redrawn example to her. I feel better. And the fact that the graphics are for children, because games are made for children, right?

    So, the development process has begun.

    Big mistake times

    I made the first mistake almost immediately when I thought about the level constructor. After some thought, it dawned on me that unity itself is a wonderful constructor. And now, after adding all the necessary objects to the stage in the right places, after the level was playable and tested, I launched it on my nexus 5 and saw fps of the order of 5-10. It turned out that it was not a good idea to add all approx 400 obstacle objects to the stage at once. So 2 scripts were written, one of which read all the objects, their position and rotation angle from the stage and wrote everything into a text file, and the second subsequently read this file and created objects on the fly when their time came. Now 50 objects can exist at the same time and the nexus felt quite healthy,

    Big mistake two

    Here it is necessary to note where development began. I began with the simplest in my opinion - with a dynamic background. Those. we have 2 sprites that follow each other, and when the one on the left is hidden from view, it is rearranged to the right and the endless pipeline of two sprites continues to move. And this is precisely what caused the subsequent gross error - I did not move the player relative to the background, but vice versa. Accordingly, when new objects began to appear, they also moved along with the background, and the player continued to rest along the X axis. And here I need to say thanks to this listof the 46 most common errors. It turns out that you cannot move a collider (a component that tracks collisions) without a rigidbody (a component that is subject to all the laws of physics; well, or not to all). Those. in his advice, this list even goes so far as if such objects are created from code, then you need to create them first, then move them to where you want and only then hang the collider on them. And I have all the obstacles in the game and are just colliders without a rigidbody. And given that the background is moving relative to the player ... In general, I had to redo it. Now only the player and the camera move, and on jiayu g2 the game also works quite smoothly.

    Not such a big mistake

    There were also smaller misses. For example, given the arrangement of the colliders here:

    Of which the lower one tracked touching the ground with his feet and everything is fine, and the upper one led to a quick and painful death, it was unacceptable for the player to slip through the obstacle and touch it with the upper collider. At the same time, in the settings there is a corresponding checkbox that sets up continuous detection, i.e., it would seem, just what we need. But this only works with physics, if a player jumped and fell according to physical laws, but this should not be allowed, because in this case, sooner or later there will be displacements when jumping and the player will fall when he does everything right.
    As a result, now, when falling, 2 rays are launched, like these:

    If one beam collides with the ground, and the second with a spike, then the touch to the ground is counted. And the finish, for example, is higher than the ground. So the touch is calculated.


    Many thanks for the music to the kind people with fma who distribute it through creative commons.


    Fuh. My free time comes to an end, I have some completed project (usually all beginnings stop somewhere in the middle). About unity, given the initial store of knowledge, I now know almost an infinite number of times more, but this is still very small. I still have a feeling that all this could be done much easier and more beautiful.
    And here, in general, the game itself is tynt .

    I almost forgot! In Android'e since version 4.4, recording video from the screen through adb has become available. So I was able in 10 minutes in a movie maker to cook up any video.

    PS Thank you to everyone who has read to this place!
    It may seem to you that this is a small craft for several hours, but I spent a week of my time on it, and it was unlikely that it was such a standard work week, it rather resembled the last day before the deadline. Everyday. Although not, most of all it looks like a week-long hackathon, in. In general, I went to the countryside to recover. Thank you all again for your attention, I talked.

    Also popular now: