Showing posts with label unity3D. Show all posts
Showing posts with label unity3D. Show all posts

Thursday, December 5, 2019

Single handed shooter game prototype.

I was wondering how feasible it is to make a "twin stick" shooter game (a shooting game that uses two analog sticks on a controller, one for controlling movement, the other for aiming) but make it in such a way that can be played with only one hand. I'm pretty sure that there are people without full use of both hands that want to play games. So I was wondering how someone could design around this issue.

Noticing that gamepads can basically be cut in half and each side mirrors the other, the controls are also doing the same. Analog stick controls movement, and the bumpers are acting as modifiers, basically altering movement to allow for aiming or moving the tank. The triggers are doing the shooting, with the face buttons being mirrored by the directional pad on the left. (Haven't added any functionality to them yet, but ... they are four buttons and the pad can point in 4 directions and is oriented just like the face buttons...

(Better view the video in full screen.)

This wasn't to make a full game out of it, just see if i could control the tank and not get flustered by not being able to play the test well enough.

Sunday, December 30, 2018

This took way longer than it should. (And what I *think* it taught me.)


*Hitting hand rhythmically on the table, shacking stuff...* This Took Longer Than It Should!

Now, what does that video show anyway? Just some text with a typing-in effect.
Yeah, that's the front of it, or rather one of the 4 versions of it. It's the dialog system that I wanted to make for a game.

There's a function that loads a dialog file created from my custom dialog editor, and the dialog function looks at the NPC, what kind of a dialog they are supposed to have, and enables the correct kind of screen to show said dialog. It can be either a simple "Hello" / "Hi, you ok?" kind of dialog, a long conversation, a dialog tree with available options as buttons and lastly, an interrogation mode. Where you can actually construct questions, and if those questions are something that the NPC has the answer to, they will reply accordingly.

"Vanilla stuff" you might say and you'd be right. But this is the first time I've been trying to make something like that and on top of that I had my ideas of what I wanted to have them do. First of all I wanted the function to be "NPC-agnostic." I didn't want to have to script stuff constantly, I just wanted to pass the name of the character you are talking to, along with some flags of what kind of a dialog it is, and have it come up. Standard stuff. But then I wanted to have the system do stuff like receive an item through dialog. Or enable a new dialog topic, mid-questioning. And then I wanted to have the system to be able to control the non-player character as well, for example, you said something to the NPC that they didn't like and that perhaps made them anxious, so their pose on screen should change. But what if I wanted to have something happen externally at a certain point during the dialog?! Like something blown up or a phone ringing! And of course, it should be able to jump from simple dialog to interrogation mode.
Or! Or ... what ever! The system should be agnostic to everything! Make it able to do *whatever* "I know how I'll do it! Every dialog line can have its own flags and codes embedded in it, and the system would check those codes while it's displaying the dialog, and fire off other functions and animations all over the place! Do all the things!"

People with experience know where this is leading up to. Bloaty, messy code. It does work now, but I noticed that I'm cleaning things as I go along, and with cleaning I mean selecting blocks of code and hitting "Del".

Since the dialog system in my mind was a single thing, I did just that. Made a big file with lots of functions in it, for the various dialog types.

NO! *table-hitting intensifies*.
Don't do that George. Had I asked around some more I think it would've been obvious that it will just make the code hard to follow when I would inevitably need to revisit it later on. A bunch of functions clumped up together without needing to talk to each other.
Since there are different flavours of the dialog, have a file for each dialog type with only the relevant functions to that type together. And for the dialog lines that were read from the file, just use a single struct to place them in and have it being read from the different dialog classes. It doesn't have for everything to be in the same class.


In the video just above, the first NPC is asking our main character to go and interrogate the other Character about stuff. (That Character's name is "Ch". Yes, I was feeling creative that night... Now that I think about it, it should be Ch1 and Ch2. Oh well.)

The video shows 3 different types of the dialog system at work, yes the visuals do need work and not all places have that "type-in" effect - but it's coming. It's a  caller-friggin-agnostic function now so all that needs to be done is to call it for that dialog panel...

Simple dialog, that unlocks the dialog tree type for the other character, which in turn leads to the interrogation mode.

*Hits table* Don't Make Monolithic Systems If You Don't Have To.

Oh btw, there's a ready made 3rd party system for dialog that could be utilized...
I guess it can be modified to do *all the things* and become monolithic blob if required. 

Tuesday, October 31, 2017

Know your self. - VR app idea.

We know our selves by what others say about us mostly. What you are able to see immediately are your hands and feet. Even your face, you are seeing that flipped over if you see it through a mirror, and photos don't convey much about your physicality most of the time because you can't see your self walking; you can't understand your own stride.

We could use tech that's readily available today though to sort of fix that. With the use of a 3D depth camera we can both capture our bodies and even animate them with motion capture. And i'm not talking about the expensive motion capture used in movies. We can use a €200 depth camera along with a €80-€100 3D tracking application. For the mesh we can use one of various free depth-to-3D software with said scanner, or use photogrametry. (You take a crapload of photos of your subject in a sphere arrangement, only looking inwards instead of away from the center of the sphere, then feed the photos to a software that will generate the 3D object along with the right colors.)

Then wear your VR helmet and walk side by side with your self, or stand back and actually watch how you move about . Of course you'll need to know how to use a game engine like Unity or Unreal, but heck, everything is there. All the tools needed are readily available.

"Why don't you do it then?"
I would, but i'm in the middle of something else. Shouldn't take more than a month even if things go south at some point :P. Any takers? A uni or something?

Tuesday, November 22, 2016

101 texturing aimed at mobile games. (Just bake'em all in there)

Yes, mobile GPUs have gotten really fast. Yes, they can make more things than consoles from some years ago. But there is still something that hasn't improved yet. Battery life.
Forcing more fps means less battery life and a hotter device. But more so does giving more stuff to the GPU/CPU to calculate. Of course they can do effects like normal mapping and real time shadows, reflections/ refractions... But when running on a device that its battery only lasts for one or two days when on standby, that isn't such a good idea.

So... what's usually done on the art department is to cheat a bit.
Consider the scene below. From certain angles the floor looks as if it has some overhang and a relief/sculpted effect. (It's used in fact in a lot of places in the project).


The most common way to do so in a 3D project would be to use a normal map in order to give the lighting information to the rendering engine and have it react correctly with the lighting.

But in a mobile environment you'd want to have the device have the least amount of work to do possible. Think of PCs and consoles good at marathons, with mobile devices good for sprints. Even though a Nintendo 3DS or a PlayStation Vita are mobile consoles running on batteries, they have chips with relatively slow speeds running as fast as they can, while mobiles are given fast, multi-core chips; and we are trying to give them as few things as possible to do, because the more you give those chips, the faster they'll go, and the more battery they'll eat up.

So back to the scene; see that chiseled effect that gives some highlights on the sides? Or that shadow effect? Well those are all baked into the texture, meaning basically that they were pre-drawn in the picture that gets wrapped around the 3D object. Lighting is faked as well, with only a couple objects actually using lighting calculations done in real time. (The ball is one of them since you will be moving it, faking it on the ball won't do as the highlights won't move. It has a small normal map to give it bumpiness. It's ok to do stuff like that if they aren't covering much of the screen.)



Above you can see the actual model of the platform blocks with no textures and in the lower right corner part of the texture atlas that has the texture info for all the platforms in this scene.
Which is another way to save on resources; placing as much stuff as you can on a single file so that the engine will only need to read one file once - but do that for things that won't be needed in a different scene. If you take a single object that uses this texture and put it into another one, then the engine will have to load the textures for that scene, plus the whole texture for that single object even if only a small part will be shown on screen.

All the shadows and highlights in the texture detail shown in the corner above were made in Photoshop, while the ambient light and shadows visible in the scene were precalculated by the engine and saved in their own image file as well. So that information is not being calculated while playing the game. That has its own limitations, but it helps in lowering the work needed. Since the light source and/or the platforms don't move, painting the highlights and shadows before hand saves on resources.



  




Monday, June 8, 2015

Nooby Unity tip - why you need prefabs.

Some people will tell you to use prefabs for safety and some will tell you for convenience when assembling scenes. Both reasons are true and more than enough, but I like prefabs for one more reason.

It makes it really easy to select complex elements in your scene that are made out of multiple gameObjects. Even if you have a label on your complex element, it will only select the whole thing if you click on that label. But if it's a prefab, it will select the whole thing anyway instead of the individual gameObject that is right under the mouse pointer. If your complex element doesn't have a prefab connection, it will select the individual gameObject that is directly under the mouse pointer. Want to select a single object in your prefabbed element? Just click again. (Or just directly double click on that object in the first place.) Handy for moving things around the scene.


Left object has a prefab connection, right one doesn't. I'm only clicking once on them, both have labels. Click on the GIF for a better look.
Adventures of a Rubber Ball thread.

Friday, September 12, 2014

Design/graphics cheat #2 - Mobile gaming

Mobile gaming is all the rage now, and companies are showing their latest phones, tablets, phones the size of slippers and chipsets for 3D graphics on-the-go.
Everybody are now showing off some awesome looking shaders, effects and high polygon (for mobile) models making sure you realize that it's rendering in real time. There's something that they don't show a lot though and that's real time - level wide shadowing. And there's a good reason for it as well; it's probably one of the more resource intensive stuff to pull off well enough, so people making games are resorting to all sorts of trickery like "baking" lighting, drawing the details in the textures instead, using shadow "blobs" for stuff that's moving... in general cut using realtime shadows in mobile gaming as much as possible.
(It can be done of course, but most of the time you'd be better off faking it and pushing your savings on making the game run at more fps or implementing some more resources into your enemies.)

So where am i going with it? 
Be smart in hiding things and using simple geometry to make shadows. Like the image on the right; those two things are just some of the obstacles in a game i'm trying to make that spew snow balls. 
I really wanted to have some slight shadowing/ darkening effect in those barrels. Light mapping wouldn't work of course because ... that's not how it works... and real time shadowing would be no-no. 


On a game you are trying to include as many devices as possible after-all to potentially have a larger install base. So it's back to old-school tricks, back to basics if you like. The barrels simply have 3 simple planes, with just 2 polygons each, and a simple black texture. Then the texture's alpha channel is set as semitransparent. Each plane will progressively make it look as if it's darker and darker the deeper you look. Of course this will only work for stuff that aren't out in the open.

For things that are out in the open, what someone could do is mark areas with simple trigger boxes that are placed in shadowy areas. Then have a simple script that would smoothly make the texture of the object that enters the box's volume darker, and lighter as the object exits. A poor man's light probe if you like. These things do require tweaking though, but the plus is that your game's speed won't suffer and you'll get some nice looking stuff.

Tuesday, March 25, 2014

Unity3D mobile quicky noobie note.

So you are making something in Unity for mobile (lets say Android). You went ahead and selected your resolution in the preview window ("Game" window) And set your GUITextures with pixel inset values in the inspector. You might have even made a script that calculates things according to the screen resolution in X and Y to find ratios and what not. Then you deploy and you notice that something is off by a couple of pixels. You double check and things are ok but still get shifted in the screen.

So what gives? Well, Unity may have 1280*800 or other standard resolutions built in, but what the OS gives to the player once you actually have it running on the device is not exactly that. Remember it has the home bar. So that takes some pixels away from the real-estate, 28 pixels as far as I could tell in the case of 1280*800 screen resolution.

Just make a custom preview resolution of 1280*752 so you won't have to keep that in the back of your mind. I'm sure there are other a lot more elegant ways of solving this, this is the easiest thing I thought about.

Tuesday, January 21, 2014

Noobie trap in Unity. (Or "How time flies". Or "Time.deltaTime")

So i wanted to make a small timer in the upper left corner of my small game.
Extremely easy; you just have a variable storing float values and add Time.deltaTime on every frame to it (deltaTime is the time it takes to render a frame.)
Thing is, if you are using something other than "1" in time scale or playing with timeScale to do some slow motion effects, your timer will get out of sync with the real time that has passed. If the timer is to trigger an event in game to happen, no biggie.
If it's for stage scoring or leaderboards though, then the timer needs to be in sync.
So just take into account timeScale. Just divide Time.deltaTime by timeScale to always keep the timer counting in the same speed. (i.e. real speed, the same speed that a wall clock does).

timer+=(Time.deltaTime/Time.timeScale);

Wednesday, December 25, 2013

2nd Maya/Unity quicky. (animating object with multiple individual meshes)

Have you tried to put your animated FBX from Maya and it would just go to 0,0,0 when you pressed play? (If you don't freeze the model before you export it, do so. Freeze it at 0,0,0 to save some extra trouble later on)

The reason for that is that most probably you have nested the meshes under a parent mesh in the Outliner panel and then on top, you've added keyframes to that parent. At least that was my problem when throwing it in Unity.
What you should do instead is select your meshes, group them, and then go in and add your keyframes and blend shapes. Export and your combined object won't crap itself in Unity.

Sunday, August 4, 2013

Paddle Trouble update.

Just a small update on Paddle Trouble. It's now posted in 2 other app stores other than Google's Play;
Amazon's Appstore and SlideMe. (And between you and me - and anyone with internet access) SlideMe and Amazon, both have done a great job in promoting things, and supporting a lot more countries for paid apps; a lot more than Play.
So to those wanting to make their own stuff, consider 3rd party appstores from the get go on top of the 1st party one.


Free version at:

Get it on Google Play
Get it on Amazon appstore



Paid version (no ads and leaderboards if you have Play Game Services installed and a G+ account) at:

Get it on Amazon appstore



And yes... i know i should make a small site aiming the game instead of posting here... :P

Wednesday, June 26, 2013

Paddle Trouble

Muaahahaaaa. My 1st video game is out (Click for tablet version) :D It seems the time is perfect now for someone to make a game if they want to. The tools are there, the outlets are there...
(For phones: https://play.google.com/store/apps/details?id=com.paddletroublemobile.game)


Monday, June 10, 2013

Visual cues

Since we don't have radar or distance sensors embedded in our brains yet, we need to rely on our eyes and ears for cues on where something is, and this is even more important on video games since unless you use a 3D monitor, the view you are seeing is 2D. (Yes, even with 3D games. The monitor is still a flat 2D plane where everything is squashed into a single,flat view, so there goes your stereo vision)

So what can be done visually wise? Shadows someone might say. Well yeah, that is number one in the list but it's not just that. There are a couple things more that can be done in the levels themselves to show the spatial relationship of things. (Spatial relationship, bet that made me look smarter than what i am). Take a look at the image below for an example.

The image shows a level from a game that you have to stop the blue balls from falling in the pit, a pretty basic premise with no story behind it. The top part has the shadows disabled. It looks as if the balls are just pasted on top with little to tell you the distance from the ground at a glance and you don't really have time to observe because that thing is coming at you and you need to throw it back. The bottom half has the shadows enabled and the player can see exactly where on the playing field the ball is and how high.

But that's not the only cue. The pit is textured in a checkerboard like pattern. That makes it even easier to tell where the ball is going to be the in the future (since the balls fall towards the centre, you can use the pattern as a guide) and give you time to turn the paddle at that angle to throw the ball back. There is also a trail effect. That not only shows the general direction of the ball but also if the ball is going up or falling down, its angle and its speed.


(The shadow may look as if it's a bit ahead of the ball but actually it's right under it. The camera used is wide so it makes it look like that, a tiny bit - sort of - fisheyed).

P.S. Since this is for a mobile game, the shadows are not real time.The shading on the level and glove/paddle are baked (drawn) into the texture and the blob under the balls is from a script solution from Unity's Asset store.