Finally doing something useful instead of promoting my game. Today is the day the foundation for a new project has been laid, and it started with pathfinding for my future virtual minions.
A* (pronounced “A star”) is a best-first pathfinding algorithm which produces least-cost optimal path from point A to point B, you can read everything about it on Wikipedia, but you don’t have to implement it yourself, not because I’m sharing my Unity3D C# static class with you, but because there’re probably a hundred of different implementations already.
Made a small vid showing how it works:
(Notice capsule moving diagonally in open unobstructed spaces – that’s a result of pretty simple path smoothing addition I made to classic A* implementation.)
I already used A* pathfinding algorithm in Railyard for building routes, but back then it didn’t account for obstacles and there was no path cost estimation. Now I finally made it something complete. My implementation uses spherecasting to check for obstacles in a way characters won’t hit corners when traversing the path. (Make sure your obstacles are on “Obstacle” layer and they all have non-trigger Collider on them.)
Now, open that gist, copypaste into your project and use
AStar.FindPath() method, supplied with two Vector3’s to find best path between them. You want smooth, non-“pixelated” path like in the video? Use
AStar.SmoothPath() with a path from first method to get it smooth. You’ll probably need to adjust some values to be in the scale of your game (I use 1.0f scale everywhere, mind that), so read comments in the class, there’s enough info for you to understand what’s under the hood.
Go now, you can thank me later.
Some wordy words about why you should support my game (or someone else’s anything that looks like an actual game) on Greenlight.
You see, when everybody was too busy building Flappy Bird and 2048 clones, I tried and built something more innovative and unique than 90% games out there on various markets. Not because I’m, like, some fucking anarchist “don’t tell me what to do” type, but because I thought it would be fun to play. Of course, I’m not running a charity here, and I plan to finally make gamedev my only trade – if my game gets on Steam.
Most indies don’t make millions, despite what you might think. But every “yay” vote, every retweet, repost, every purchase however small, gets us something more than just money. It’s recognition and acceptance. It’s strength and courage to continue our work. So when you don’t support indies, you fuck us up and will never see what else we got prepared for you.
Word of warning – if you don’t. Karma’s a bitch, you see. You vote “nay”, you steal our shit, download torrents – you’ll be left all alone with some corporate fuckers like EA, King.com, Supercell or Zynga, who in cold blood able to murder whole genres – just because of money. Soon you’ll be left with no games to play and no indies to build you games you’d wanted.
I’m working on a complex game engine, which will let me build not one, but two games I already thought of. Both roleplaying/strategy/simulation, both rely heavily on social mechanics (not “social” like invite-your-friends-from-fucking-facebook-to-get-some-points, social like your characters actually have to worry about something more than just their health points), both with plenty of mature content, procedurally generated maps and such. Both will keep you entertained for days, if not years. Wanna see them done and released? Don’t support pay-to-win. Don’t support stupid farms, villes or any other shit that sucks your wallet. Support indies. You can start with me.
Here’s another portion of Unity3D beginner tips and tricks, and today it’s about using physics engine for something more than just making things go bump. (Pic related.)
Did you know, that every collider you click/tap sends an event to all the scripts attached to the same
gameObject? Now you do. Implement
void OnMouseDown() method in any of those scripts to get the message. Make sure your object is not in Ignore Raycast layer though, ’cause raycasting is what making these messages possible. A pretty useful mechanic for implementing UIs (since you can attach colliders to virtually anything) or otherwise interacting with objects in the scene.
Next one is more complex. Let’s say you got objects that need logical connection to each other. See Railyard, trains are being made of cars of the same type. First solution that comes into mind is just store references to cars in arrays and do a bunch of array processing each frame. (That actually works, and I did implement that in the early prototype.) But making your hardware do extra work is unnecessary, especially when you have access to a perfectly optimized physics computation.
So, what I did was this:
Except main collider used for actual collisions and destruction, every car has two sets of colliders – box and sphere, with sphere colliders being triggers. Note: triggers ensure non-trigger colliders will go through them, and redundancy of colliders on each side ensure
void OnTriggerEnter() will run on every car no matter which one initiated a collision.
Rest is also simple – on every trigger enter event a link between two cars is created if it doesn’t exist yet, link being a simple
struct with two references to cars. Link is placed to a simplest collection possible (I used C# List). On every trigger exit event existence of a link between two cars is checked and link is destroyed if exists.
I find this realization simple and efficient when it comes to something like match-3 games, so if you’re doing one, hope it helps.
It’s pretty easy to get me mad. Generally, I hate idiots, whiners and lazy-asses, and I instantly get mad when they appear in my info-space, be it online or offline. But there’s one more category of people whose mere existence gets me fucking frothing foam at me mouth when I think about it – greedy kids. This particular rant brought to you, in part, by greedy gamedevs on Kickstarter.
Imagine yourself a game project which is nothing special, typical top-down arcade for mobiles, built with Unity3D, more than halfway there (judging by the videos and screenshots), looking to raise a whooping $40K on Kickstarter.
I’m not a rich man, you know, but a pretty good developer. $40K is what I’ve been doing in a year as a Senior iOS Developer in a major russian mobile-dev company. That’s enough for a family of three to live a beautiful life for a year – in Russia. So, imagine my reaction when I see a project which is month (max) until it’s ready asking for that kind of money. I’m really struggling to find an English equivalent of Russian “да вы охуели”, because “you fucking outta your fucking mind” doesn’t nearly have the same level of expression.
You think that’s all? There’re stretch goals in their project, first being PC/Mac/Linux version if $75K is pledged. Just think about it – a Unity3D game for mobiles, turn the camera from portrait to landscape, adjust it a bit, throw in couple lines of code to enable keyboard/mouse/gamepad controls that’s already in the engine – hurray, $35K covered. WHAT? I’m really struggling to find Russian obscene lexical equivalent for my emotions on this one.
There’s a reason for my rage. Railyard: Match-3 Evolved is a project I soloed in 2 months and released for 5 platforms, take a look what a single dev can do with a budget of $500. (It would’ve been $200 less if I wasn’t so picky about Unity3D free-vs-pro features.)
Stay fucking hungry, no matter how many millions your projects made. And if you really want to back some Kickstarted campaign, back these guys ’cause they’re oldschool and doing an awesome job.
As of today’s morning, Railyard: Match-3 Evolved is finally published on 5 platforms – Android, iOS, Windows, OS X and Linux.
Last week was a fucking blur. Launched Android version on 23th, got no attention, proceeded to build a desktop version, released yesterday, at the same time receiving the message from Apple that iOS version got approved.
If you’re gamedev going to publish your first game, here’s some advice.
Prepare your audience, build your brand recognition, round up some press people, rally your fans – all before release.
Don’t rely on your Facebook friends and Twitter followers, they will not like, repost or retweet. It’s not like they’re being total dicks, it’s just what people are – you can be drink buddies, schoolmates, colleagues, but they don’t give a fuck about work of your life if it’s outside the sphere you two interact in.
A video is worth a hundred screenshots. Make at least one trailer and at least one gameplay video.
Post everywhere and every day. Get used to post into #gamedev and #indiedev on Twitter, /r/gamedev and /r/indiegaming on Reddit. Get included in all the indie databases. Never forget to link back to your game’s official page/site.
And may the gods of indie gamedev watch upon you with a smile, because if they’re not, you’re fucked.
Everybody in #gamedev today seem to be hyped by the recent blog post about what game designer does. You can read that, if you want. But don’t. You already know what game designer does, or at least you can make an educated guess. (If you can’t, you probably in the wrong blog.)
Here’s an unpopular point of view – not everything needs explaining. Imagine yourself a game designer, who had to spend an entire hour of his precious time to explain what he does for a living to his relatives or schoolmates he sees once in 5 years or so. Time is now wasted. Does he feel better? Does he? What changed in his life? What the knowledge he brought changed in the life of listeners? The answers are “no” and “nothing”.
If you need to explain, you don’t have to explain, so don’t. Mind your game. Players don’t give a flying fuck about your roles in a team, they only care about final product and the team as a whole.