|
Polo-Rican posted:Kind of annoyed that I can't do something simple like var particlesystem1:ParticleSystem = this.[NAME OF CHILD] as ParticleSystem. dupersaurus fucked around with this message at 23:33 on Jan 22, 2014 |
# ? Jan 22, 2014 23:31 |
|
|
# ? May 24, 2024 12:48 |
|
dupersaurus posted:
This might help. GameObjectEx is my set of utility functions for finding components and game objects. I end up never using it (scene-wide searches are usually a bad idea), but if you need that functionality, it'll probably help. Lets you, for instance, find a comomponent of TYPE in the scene belonging to an object with a given tag. EDIT: You know, while we're at it, here is my AudioSourceEx, which automates spawning sound clips from a pool instead of Instantiating them on the spot in super-slow fashion, and here is the SoundManager singleton that powers it. There's a lot of gunk in there you won't care about, just pasting it so that you can see how it acquires the SpawnPool. The spawning stuff only works if you have PoolManager2... but you really, really want to get PoolManager2, generally speaking. Instantiating things will cause you endless pain and hitching. My AudioSourceEx variant also automatically randomizes pitch/volume within sane bounds, to break up identical sounds being repeatedly played. UE3 makes that easier with its audio graph stuff, but that little tweak covers 90% of what I would have done in UE3 anyways. Shalinor fucked around with this message at 23:40 on Jan 22, 2014 |
# ? Jan 22, 2014 23:35 |
|
Shalinor posted:The spawning stuff only works if you have PoolManager2... but you really, really want to get PoolManager2, generally speaking. Instantiating things will cause you endless pain and hitching. Are you talking about this one?
|
# ? Jan 22, 2014 23:55 |
|
Obsurveyor posted:Are you talking about this one? Why spend $30 when all you really need is this: code:
|
# ? Jan 23, 2014 00:34 |
|
xgalaxy posted:Why spend $30 when all you really need is this: Because it's worth a few bucks for an elegant, well-designed solution as opposed to quickie hack approach. This ends up at the core of literally your entire game... it's worth making it more than "useable." Shalinor fucked around with this message at 02:59 on Jan 23, 2014 |
# ? Jan 23, 2014 00:55 |
|
Shalinor posted:Because it's worth a few bucks for an elegant, well-designed solution as opposed to quickie hack approach. This ends up at the core of literally you entire game... it's worth making it more than "useable." And $30 for a tested, working solution is highway robbery vs. rolling your own.
|
# ? Jan 23, 2014 00:56 |
|
As a follow up to the question I just posted, I completely understand now. I'm just a huge idiot dummy and fundamentally misunderstood how naming and creating objects works. I got confused because, when I chose "Create Particle System," I was in the mindset that I was just creating a particle system, when really what you're doing is creating an empty game object with a particle system in it. Therefore, I was mistakenly thinking that I was naming a particle system itself, when really I'm naming a game object. Tranform.find() followed by getComponent was actually what I was looking for.
|
# ? Jan 23, 2014 01:08 |
|
Polo-Rican posted:Yeah, that works, thanks! I'm just being a whiny baby but it's annoying that you have to iterate through an array of results in a system where you can give each object a unique name. GameObject.Find("myParticle").GetComponent<ParticleSystem>(); Edit: holey moley was I late on this one!
|
# ? Jan 23, 2014 01:14 |
|
Polo-Rican posted:Yeah, that works, thanks! I'm just being a whiny baby but it's annoying that you have to iterate through an array of results in a system where you can give each object a unique name. If you are cranky with the behavior of GameObject, it's also pretty easy to extend classes via partial classes in C#, just jam this in your code somewhere: (I'm not necessarily condoning this technique as a general purpose tool, but sometimes it's just a practical way to keep from repeating the same stupid bullshit over and over again in a way that's a nightmare to maintain) code:
Unormal fucked around with this message at 01:26 on Jan 23, 2014 |
# ? Jan 23, 2014 01:23 |
|
Unormal posted:If you are cranky with the behavior of GameObject, it's also pretty easy to extend classes via partial classes in C#, just jam this in your code somewhere:
|
# ? Jan 23, 2014 02:58 |
|
SupSuper posted:You can also use Extension methods which are specifically designed for this purpose (doesn't work for static classes though).
|
# ? Jan 23, 2014 04:16 |
|
Unormal posted:If you are cranky with the behavior of GameObject, it's also pretty easy to extend classes via partial classes in C#, just jam this in your code somewhere: Fake edit: I asked Google and the answer is yes, so long as one of them uses the class name as its filename the names of the others don't matter. Sweet. That'll make organizing the occasional overwhelmingly giant class much easier.
|
# ? Jan 23, 2014 05:18 |
|
roomforthetuna posted:Can that kind of thing also work for splitting your own classes into two files, given Unity's insistence on having the filename match the class name? However, it's usually preferable to split a big class into smaller ones than using partial classes just to make it seem smaller.
|
# ? Jan 23, 2014 07:07 |
|
xgalaxy posted:Debug.isDebugBuild is an abomination though.
|
# ? Jan 24, 2014 09:35 |
|
Any good guides or books on making a first-person/shooter game in C++? Preferably one with some milestones so you can finish a chapter or section with something tangibly finished instead of having to reach the end for anything to show for it.
|
# ? Jan 24, 2014 23:27 |
|
Put as much behaviour as you can in static methods and extension methods. They're great because (as long as you dont go crazy with static variables) you can very easily see what they depend on and what they affect. Even better, you can hang extension methods off interfaces, each of which can represent a different role that the object plays in your program. (They're not as good as mixins or traits though, because you'll sometimes find yourself wanting to violate encapsulation in order to implement something as an extension method. It's up to you to decide whether the tradeoff's worth it) As an aside, if you find yourself having to pass seventeen arguments into a method in order to make it static, that's a good indication that the method is doing faaar too much work.
|
# ? Jan 25, 2014 10:48 |
|
I'm just gonna come out and say - Unity is amazing. I only ever had experience with UDK before, from a college course, but I entered GGJ14 at my University and got thrown into the deep end of learning C# from scratch with a friend of mine. It's about the nicest language I've seen apart from Python, which obviously has no major game engine support, and the seamless non-hacky way it integrates with MonoDevelop is great. I think I have the game dev bug.
|
# ? Jan 27, 2014 02:05 |
|
I had a slightly negative impression of Unity when I opened it up for the first time, because I jumped right in without opening any tutorials at all. So I could not find my way around at all. After getting my head out of my rear end and checking out some videos, I really changed my opinion about it. I am already getting more ideas about what to make!
|
# ? Jan 27, 2014 03:01 |
Yeah as someone who is totally new to this I'm finding Unity to be really impressive. I was pretty much lost at first but after a few tutorials I'm starting to get the hang of things and having a lot of fun with it. I think I may be most impressed with how easy it makes it to rapidly prototype things. Particularly with the new 2D tools. Things can still get complicated, but it's amazing how much functionality you can pull off really simply.
|
|
# ? Jan 27, 2014 03:45 |
|
The most important thing I've learnt about Unity is to minimize the amount of code that talks to the engine, because you need to load a game instance to test anything that does. Classes that make no reference to Unity can be instantiated in any old unit testing framework, which means you can iterate on them much faster. e: oh poo poo, they released an integrated framework for unit testing last month
|
# ? Jan 27, 2014 03:53 |
|
coffeetable posted:The most important thing I've learnt about Unity is to minimize the amount of code that talks to the engine, because you need to load a game instance to test anything that does. Classes that make no reference to Unity can be instantiated in any old unit testing framework, which means you can iterate on them much faster. (yes, I know, some actually do, but everywhere I've worked, the unit testing framework is a sad, dejected thing that the tech director forced in and then no one ever really made use of)
|
# ? Jan 27, 2014 05:08 |
|
There was some talk about networking solutions, and if you are using Unity I can recommend Photon Dedicated Server. It has a dedicated server available which seemed quite functional with decent example code. The server is written in C# on top of a C++ dll, so it's easy to work with if you're already working with Unity. They also have a cloud based version of the server, which you can setup in minutes, with their custom Unity classes. I don't have a ton of experience with it but when I was checking it out a few months ago for a project it seemed like a pretty good way to set things up (I know nothing about networking).
|
# ? Jan 27, 2014 11:12 |
|
Shalinor posted:This would matter a ton, if anyone actually used unit testing I was just speaking from experience on personal projects, so welp. Does the game industry consider version control and bug tracking to be passing fads too?
|
# ? Jan 27, 2014 13:03 |
|
coffeetable posted:I was just speaking from experience on personal projects, so welp. Does the game industry consider version control and bug tracking to be passing fads too?
|
# ? Jan 27, 2014 14:06 |
|
coffeetable posted:I was just speaking from experience on personal projects, so welp. Does the game industry consider version control and bug tracking to be passing fads too? We don't do unit testing, but we do definitely have version control and bug tracking. Our biggest complaint about unity has been lack of integration for source control (the asset server sucks); to get it to play nice with perforce we're having it save all prefabs as text files and having it spit out meta files. It works but is kinda hacky.
|
# ? Jan 27, 2014 14:35 |
|
We have unit test coverage (most) systems, including game systems. I have a love/hate relationship with them though. It's like "yay, I finished writing all my code!" then "Crap, I have to spend that amount of time again writing tests for everything!" but at the same time when we're adding new things and unit tests break, it's a wonderful lovely world. Or if we're writing server code, we can get the system up and running without a lick of UI of code. I just have to convince myself the upfront cost is worth the pretty sizable schedule hit. Edit: We barely write any unit tests for Unity proper, but they did just release their testing framework last month: http://blogs.unity3d.com/2013/12/18/unity-test-tools-released/
|
# ? Jan 27, 2014 14:59 |
You should check out test driven development. Write the unit tests, then write the code that is used by them. Although I don't see unit testing done as much in games. It's just not as simple to do and a lot of the bugs exposed through testing come from very complex inputs. Imagine creating a unit test to see if you can go through a block by jumping backwards in mario.
|
|
# ? Jan 27, 2014 15:35 |
|
Manslaughter posted:Imagine creating a unit test to see if you can go through a block by jumping backwards in mario. That's not unit testing, that's validation testing. Unit tests are intended to be on single units of code (ie, methods or classes), to ensure they do what the author intended them to do. You achieve this by isolating the unit from the rest of the system. What unit tests don't cover the author's intended behaviour being different from how the system expects the unit to behave. In your example, the unit tests would be things like "Is Mario considered a physics object?", "Is a block considered a physics object?", "Do physics objects from each of these position/velocity/size equivalence classes always report a collision?". Those cover a whole bunch of developer fuckups, but they don't cover things like the developer making special snowflake physics object for Mario and hand-crafting its interactions with normal physics objects.
|
# ? Jan 27, 2014 15:50 |
|
coffeetable posted:That's not unit testing, that's validation testing. Unit tests are intended to be on single units of code (ie, methods or classes), to ensure they do what the author intended them to do. You achieve this by isolating the unit from the rest of the system. What unit tests don't cover the author's intended behaviour being different from how the system expects the unit to behave. Came to post basically this. The Unit Tests would be more like, "If the input system has full right and on the same frame full left and jump is pressed simultaneous is the output to the physics system correct?" That and if the team has a strong culture of "Any bug fixed must show a failing test first." Then the tests will quickly help regress these issues. Once you get to cross-concerns you're out of the realm of unit tests.
|
# ? Jan 27, 2014 15:56 |
|
Hughlander posted:Came to post basically this. The Unit Tests would be more like, "If the input system has full right and on the same frame full left and jump is pressed simultaneous is the output to the physics system correct?" That and if the team has a strong culture of "Any bug fixed must show a failing test first." Then the tests will quickly help regress these issues. Once you get to cross-concerns you're out of the realm of unit tests. I'm going to guess it at least has to do with the type of studio you are. If you're actually doing low-level engine work (ie. usefully unit-testable code that's highly cross-dependent and sensitive) constantly, maybe unit tests matter. Maybe they would be useful to, say, Unreal Engine proper, or CryTech. I'm entirely skeptical of their usefulness to "studio that makes games," though.
|
# ? Jan 27, 2014 16:08 |
|
coffeetable posted:In your example, the unit tests would be things like "Is Mario considered a physics object?", "Is a block considered a physics object?", I always wondered whether a lot of "you can't possibly do anything without unit tests" stuff comes from using dynamically typed languages. In a statically typed language you don't usually need this type of test, but I can see how you absolutely need them to compensate for the ineptitude of dynamic languages. I'm not saying "automated tests are bad never use them", just that I wouldn't quite consider them as indispensable as a SCM or a bug tracker
|
# ? Jan 27, 2014 16:22 |
|
Zlodo posted:I always wondered whether a lot of "you can't possibly do anything without unit tests" stuff comes from using dynamically typed languages. In a statically typed language you don't usually need this type of test, but I can see how you absolutely need them to compensate for the ineptitude of dynamic languages. Those hypotheticals weren't literally "the Mario type has interface/ancestor PhysicsObject", they were "Does Mario register correctly with the physics manager?" To be fair I'm a newbie, but I work exclusively in strongly typed languages and tests are still indispensable.
|
# ? Jan 27, 2014 16:25 |
|
I think it's more "are you making the engine or using a predefined engine". I'd say a good rule is the lower level your code is the more likely you should be using unit tests. If you're making a game engine, yes, definitely. If you're making a game with that engine, not so much. Something like unity can benefit from it but unity's a loosely coupled component system so it's not like changing one thing has a big domino effect that unit tests try to prevent. If there's a bug with a thing chances are, That Thing has the bug, not some other obscure class buried deep in a codebase like with a lower level language or tightly coupled engine.
|
# ? Jan 27, 2014 16:31 |
|
coffeetable posted:Those hypotheticals weren't literally "the Mario type has interface/ancestor PhysicsObject", they were "Does Mario register correctly with the physics manager?" I write tests for stuff that involves a fairly long winded algorithm or a very self contained system, so I know I can trust then to work. For things like "does class x actually does y like it should I prefer to rely on debugging, since it allows to focus to only the stuff you got wrong, so it takes less time Of course it's not as nice when refactoring things, but when I work on personal projects I already have a hard time enough keeping motivated as is and I just hate writing tests
|
# ? Jan 27, 2014 16:39 |
|
I don't write very many tests. I'm not imaginative enough to think of tests, or ways to test complex, intertwined code, which I write a lot of. I'm quite bad at that. But every time I've worked with a codebase with exhaustive tests written by something else, I feel a lot more at ease. Instead of imagining if my code will do the right thing or if it will break something else and getting tense about all the possible scenarios, I can just run make check and see maybe what broke.
|
# ? Jan 27, 2014 17:05 |
|
Unit tests are an absolute slam dunk no brainer for certain types of code. They're also pointless busywork for others. A sign of a good engineering organization is that unit tests exist but are not mandated by management in any systemic way. (I will never, ever, ever go back to working for a company that does metrics of unit test code coverage. That results in the stupidest poo poo I've ever seen where unit tests are written for trivial getters, yet complex interactions between systems are never tested because there shouldn't be any bugs as long as our coverage is over N%.) One of the things I really like about the games industry is that programming video games is hard enough that we tend to not have any extra engineering resources to pour into following fads like dogmatic TDD or using the new language du jour for each project. But because time is so valuable anything that is a genuine increase in productivity does tend to stick.
|
# ? Jan 27, 2014 17:28 |
|
In my brief time with some Ruby I was exposed to Behavior Driven Development, or BDD for short. In particular to Ruby, there was a very cool framework I used for this called Cucumber. In addition to this framework was an automation suite that could read the behaviors and run the behavior steps automatically and would then report failure or success. This was amazing for a lot of the UI heavy stuff because it could run through clicking all the buttons, inputting text, and navigating to all the pages, etc, all automatically like someone had recorded the steps in a macro. I feel this type of testing could be really useful for games. Only code I tend to unit test is very core systems level stuff.
|
# ? Jan 27, 2014 17:46 |
|
Yeah, I don't think that unit tests are good for games. The only thing I can think of is "given these inputs into the physics engine, test that all the values are correct". And then you add CUDA-based physics that's nondeterministic. Or you change the player model so that the hitbox is slightly different. Now he's at 2,654 instead of 2,755. Is that a bug? Wait, I ran it again, and now he's at 2,650. Bug? For bugs like a sticky collision system where players might get stuck in a wall or fall through the floor, an automated regression test against a set of specially-made maps testing pathological cases, extracted from in-game assets would probably be useful.
|
# ? Jan 27, 2014 17:47 |
|
Tests are also a good penance for creating a bug in the first place; I always try to write a test that would have caught a bug I just fixed, if I can. I just don't know whether videogames are usually that simple.
|
# ? Jan 27, 2014 17:53 |
|
|
# ? May 24, 2024 12:48 |
|
One more story I need to share about TDD. Before I worked in the games industry I was at a company that produced aerodynamics software. The engineering team had a couple of young, ambitious engineers who were really excited about bringing the company's older codebase and engineers into the modern world. They'd read every blog post ever written about TDD and agile development and took to them like converts at a Baptist revival. Now, probably the most difficult thing about writing unit tests is dependencies between systems. Once one system needs to know about another you can't really call them in isolation. There are a lot of decent compromises available to handle dependency injection so that code is more amenable to unit testing. The particular one they choose is that instead of ever calling functions directly, they would use boost signals and slots for all function calls between systems. And I mean all - calling a function outside of your own class would not pass code review. So, after about a year of development on the new product using these principles, they felt really good about it. After all coverage was around 70%, and that meant they didn't need a lot of QA so they had two QA testers for 10 engineers. Time came to ship the beta, and it turns out that the software was incredibly slow and incredibly buggy. And this isn't even software that should have been performance sensitive - just the UI interactions were bogged down to hell. Worst part is, the problems with the software were intrinsic and unfixable at that point. The enormous cost of emitting a signal versus calling a function was ingrained so deep in the codebase it could not possibly be removed without starting from scratch. And the software was almost undebuggable (if you've ever tried to step through the emission of a boost signal and the ~7 layers of template functions involved you'll understand what I mean.) It was almost impossible to reason about how code actually worked since everything was so decoupled that you could never follow a code path outside of a single file. There was just no way of knowing what the hell the software was actually doing. But hey the coverage metric was pretty good. Paniolo fucked around with this message at 18:00 on Jan 27, 2014 |
# ? Jan 27, 2014 17:58 |