• Advertisement
Sign in to follow this  

Unity Gamestates and their uselessness

This topic is 2258 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In the past iv setup my simple games with using game states. A game state, at its most basic is setup like this...

class GameState {
void Init();
void Update();
void Draw();

Initialize the objects you need during the game state, update logic, draw graphics. This works and is very simple to understand.
As i move forward and expand my games, making them more complex and interesting i build myself an entity system, such as the Component model from Dungeon Siege or Unity Engine. As i add more components, through code or script, the update function of the game state becomes less and less useful to the point of it literally only telling the component manager to update.

Also i add a scene manager to my game, this manager is tied into the components, render components within the component manager handle the nodes within the scene. This continues much as before and eventually my Draw function also serve no true purpose.

Seeing as Init is now simply a laundry list of commands to piece together components and nodes it can be moved into an XML format and removed from hardcoding. Does gamestate even truly serve a purpose now? Is this the correct path i should be taking? Thoughts?

Share this post

Link to post
Share on other sites
In your case probably not. You need to find a solution that best fits your problem. Not try to fit your problem to a specific solution. If you continue to try you will be unhappy with your code and working on your project will be like going in to do battle with the framework of your game just so you can get it to behave in the way you want it to.

That sounds like something you do at work because you have to. Not something that you do as a hobby( Unless you are masochistic).

There have been a lot of good articles on the game entity architecture. I am not sure of you subscribe to game developer magazine. But they have an excellent article In last month's issue describing the past, current and future of the game entity architecture.

I believe it was the November 2011 issue. http://www.gdmag.com/
Otherwise there have been some excellent posts through-out these forums.

Although it sounds to me like you are pretty well versed in this architecture.

Share this post

Link to post
Share on other sites

( Unless you are masochistic).
I believe it was the November 2011 issue. http://www.gdmag.com/

You have no idea :) lol, ill have to check that article i havent kept up to date with reading the mag, i tried the digital version, and now i never read the darn thing. Thanks for the pointer.

Im just trying to do this stuff in my free time, learning as i go. I understand the reasoning why books and tutorials start off using somethign like a game state, but in the long run its actually hurt me because i have a hard time finding information on the more advanced systems being used these days. Iv tried to piece together what can from all over. Iv found some decent books that overview alot of differnt areas, but not much that gets into actual code. Something of an intermediate step between newbie and Unreal engine architect lol

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By Innoc uous
      I'm working on a space game, and I suck at art. I would love to get some help from someone who is more skilled than me. Things I need include modular space ship parts and GUI elements. Nothing too fancy, just functional so I can get a prototype put together. This could potentially become a serious project, but for now this is just a hobby project.
      In this video, you can see a few things I already completed
      :2018-02-24 20-08-13.flv2018-02-24 20-08-13.flv
    • By Innoc uous
      If you want to incorporate noise into your shaders, the Turbulance Library has you covered. Using code I gathered from this library, I made a cginc file that contains all you need to easily implement noise into your unity shaders. Who knows how this stuff works, but man, does it work well!
      Here is an example of what you can create using these noise functions.
    • By Nio Martinez
      I'll be buying a new laptop as my workstation for building games, Mostly 3D but not hard core. 
      I'm stuck at choosing between these 2 specs below. Does this really matter and if so, can some one tell my how and why it matters. 
      Intel core i5-8250U (8th gen Kabylake refresh)(6 MB Smart Cache, 1.6 GHz Base with Turbo Boost up to 3.4 GHz) 4 cores 8 threads
      RAM 8 GB DDR4 (2400 MHz)
      GPU 2 GB DDR5 Nvidia MX150 256 bit
      SSD: yes
      Intel core i7-7500U 2.70GHz Base Processor (4M Cache, up to 3.50 GHz Boost) 2 Cores, 4 Threads
      RAM 4 GB DDR4 (1800 MHz)
      GPU 2 GB DDR5 Nvidia GeForce 940MX 256 bit
      SSD: No
    • By Manuel Berger
      Hello fellow devs!
      Once again I started working on an 2D adventure game and right now I'm doing the character-movement/animation. I'm not a big math guy and I was happy about my solution, but soon I realized that it's flawed.
      My player has 5 walking-animations, mirrored for the left side: up, upright, right, downright, down. With the atan2 function I get the angle between player and destination. To get an index from 0 to 4, I divide PI by 5 and see how many times it goes into the player-destination angle.

      In Pseudo-Code:
      angle = atan2(destination.x - player.x, destination.y - player.y) //swapped y and x to get mirrored angle around the y axis
      index = (int) (angle / (PI / 5));
      PlayAnimation(index); //0 = up, 1 = up_right, 2 = right, 3 = down_right, 4 = down

      Besides the fact that when angle is equal to PI it produces an index of 5, this works like a charm. Or at least I thought so at first. When I tested it, I realized that the up and down animation is playing more often than the others, which is pretty logical, since they have double the angle.

      What I'm trying to achieve is something like this, but with equal angles, so that up and down has the same range as all other directions.

      I can't get my head around it. Any suggestions? Is the whole approach doomed?

      Thank you in advance for any input!
    • By devbyskc
      Hi Everyone,
      Like most here, I'm a newbie but have been dabbling with game development for a few years. I am currently working full-time overseas and learning the craft in my spare time. It's been a long but highly rewarding adventure. Much of my time has been spent working through tutorials. In all of them, as well as my own attempts at development, I used the audio files supplied by the tutorial author, or obtained from one of the numerous sites online. I am working solo, and will be for a while, so I don't want to get too wrapped up with any one skill set. Regarding audio, the files I've found and used are good for what I was doing at the time. However I would now like to try my hand at customizing the audio more. My game engine of choice is Unity and it has an audio mixer built in that I have experimented with following their tutorials. I have obtained a great book called Game Audio Development with Unity 5.x that I am working through. Half way through the book it introduces using FMOD to supplement the Unity Audio Mixer. Later in the book, the author introduces Reaper (a very popular DAW) as an external program to compose and mix music to be integrated with Unity. I did some research on DAWs and quickly became overwhelmed. Much of what I found was geared toward professional sound engineers and sound designers. I am in no way trying or even thinking about getting to that level. All I want to be able to do is take a music file, and tweak it some to get the sound I want for my game. I've played with Audacity as well, but it didn't seem to fit the bill. So that is why I am looking at a better quality DAW. Since being solo, I am also under a budget contraint. So of all the DAW software out there, I am considering Reaper or Presonus Studio One due to their pricing. My question is, is investing the time to learn about using a DAW to tweak a sound file worth it? Are there any solo developers currently using a DAW as part of their overall workflow? If so, which one? I've also come across Fabric which is a Unity plug-in that enhances the built-in audio mixer. Would that be a better alternative?
      I know this is long, and maybe I haven't communicated well in trying to be brief. But any advice from the gurus/vets would be greatly appreciated. I've leaned so much and had a lot of fun in the process. BTW, I am also a senior citizen (I cut my programming teeth back using punch cards and Structured Basic when it first came out). If anyone needs more clarification of what I am trying to accomplish please let me know.  Thanks in advance for any assistance/advice.
  • Advertisement