Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

hedgecore posted:

I'm using a model I found online which does have individual wheels but honestly I just set up a Box collider and am treating it like a large box (no wheelcolliders or anything). I'm animating tricks by rotating or flipping the whole thing. I figured this would only make things easier in the "faking it" kind of physics.
Sorry, by "model individual wheels" I meant "perform physics simulation on individual rotating wheels." For a box like that you need to set up anisotropic friction as I described. This will produce behavior that is usually sort of like having wheels.

Adbot
ADBOT LOVES YOU

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Serenade posted:

All this talk of inheritance & co makes me wonder if a mostly functional approach could be a useful way to code a game.
Naughty Dog used to write all of their games in a custom LISP derivative until they got bought by Sony and Sony forced them to start writing stuff in C++ instead.

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

OneEightHundred posted:

Naughty Dog used to write all of their games in a custom LISP derivative until they got bought by Sony and Sony forced them to start writing stuff in C++ instead.

And even then their game logic is all written in Lisp (Racket is used to compile it down to a custom byte code format for a custom VM IIRC). Well not all of it. But there's a lot of state changes and event handling written in their dialect.

hedgecore
May 2, 2004

Ralith posted:

Sorry, by "model individual wheels" I meant "perform physics simulation on individual rotating wheels." For a box like that you need to set up anisotropic friction as I described. This will produce behavior that is usually sort of like having wheels.

Gotcha, thank you. Unfortunately... http://answers.unity3d.com/questions/927201/friction-direction-2-work-in-unity-5.html Am I screwed then?

Is there a way I can just turn by setting rotation where it will still respect level geometry? Or will setting it manually cause my model to go through other models?

hedgecore fucked around with this message at 05:02 on Nov 20, 2015

ToxicSlurpee
Nov 5, 2003

-=SEND HELP=-


Pillbug

Manslaughter posted:

In a perfect world, the compiler or IDE warns me of such folly and prevents me from building.

What do I do if I want a default behavior for my interface methods?

In a perfect world we wouldn't need to write code at all.

For that you use a base class rather than an interface. Like I said you don't strictly need to ever use an interface. They're classes with fewer features. Everything an interface can do a class can do. But for default behavior that's abstract classes, like was said. I think they're called partial classes sometimes too. I never use that sort of thing and just create nothing but classes instead but then I also only work on solo projects these days.

Interfaces are more of a software engineering thing when you have to deal with a lot of people working as a team.

Fano posted:

Pity that there don't seem to be many courses that focus on how to architect a game that is bigger in scope than your typical 'make your first game' tutorial, sometimes I feel that I am making a lot of stuff up as I build up my game and that there are probably some concepts/design standards that go into building the infrastructure for a game that I'm simply not aware of since I don't work in the industry.

Then again a course on something like that is probably not too plausible since every game is different.

Big games are just big programs. That gets into the territory of software engineering. The basics of game making are always the same but once you get into making larger games they start to look more like big non-game projects. The concepts of code organization are about the same, far as I can tell, but there just isn't ever one singular hard and fast rule. Every project is different so there is literally no way to say "this is how you organize a large code base for X type of game."

Mostly it's just sitting down and planning out classes, inheritance, and organization ahead of time and sticking to it so it turns into as little of a spaghetti-riddled disaster as possible. General concepts relating to engineering and architecture apply to everything and are mostly just that; planning. Oddly enough in our software engineering class we actually started with a weird little engine and built a game over it.

Read about stuff like UML diagrams and organizing code. Really, much of it is just actually planning things and not being a dumbass in how you plan things.

ErIog
Jul 11, 2001

:nsacloud:

ToxicSlurpee posted:

Really, much of it is just actually planning things and not being a dumbass in how you plan things.

This is really a bootstrapping problem, though, since "not being a dumbass" usually requires understanding how the project is going to grow as it develops. Unless you've cratered a bunch of hobby projects through lack of organization, it's really hard to understand why certain approaches are bad since there's a lot of hacky approaches that can produce results very quickly.

RNG and strings are both great examples. It's really easy to through a bunch of RNG functions everywhere, and then really hard to go back and untangle to make a deterministic seeded RNG like is popular now in a lot of the indie roguelikes. It's really easy to throw random text strings everywhere, and then really hard to go back to refactor in order to do localization.

This is where that book that was linked before about game design patterns is really critical. It can teach you to plan stuff in a way that allows you to more easily refactor later. Stuff like wrapping Unity's Debug.Log to your own function so that you can spit logging out to a text file more easily later. Writing an RNG class that you can customize later when it comes time to implement seeded behaviors. Writing a string manager to divvy strings out so that there's a centralized place you can go to do rewrites later on.

It's really easy to stub out all of these things early on, and then flesh them out as your game progresses. It's really hard if you didn't stub those things out from the beginning.

Serenade
Nov 5, 2011

"I should really learn to fucking read"

OneEightHundred posted:

Naughty Dog used to write all of their games in a custom LISP derivative until they got bought by Sony and Sony forced them to start writing stuff in C++ instead.

Yeah, it was mentioned in a Gamasutra article from a while ago. They mention some positives but also note the pitfalls of a lisp monoculture.

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

hedgecore posted:

Gotcha, thank you. Unfortunately... http://answers.unity3d.com/questions/927201/friction-direction-2-work-in-unity-5.html Am I screwed then?

Is there a way I can just turn by setting rotation where it will still respect level geometry? Or will setting it manually cause my model to go through other models?
Honestly, you're going to keep hitting issues like this if you try and use a physics engine to drive your skateboard. The best solution is going to be to roll your own controller, for much the same reasons as you almost always want to toss out the default Unity CharacterController and make your own for a platformer game. Start with a kinematic rectangle and build up from there.

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

hedgecore posted:

Gotcha, thank you. Unfortunately... http://answers.unity3d.com/questions/927201/friction-direction-2-work-in-unity-5.html Am I screwed then?

Is there a way I can just turn by setting rotation where it will still respect level geometry? Or will setting it manually cause my model to go through other models?
Huh. I'd find some examples of wheeled vehicles (e.g. simple cars) implemented in PhysX 3 and see how they do it. You need something that behaves like that.

HaB
Jan 5, 2001

What are the odds?

ToxicSlurpee posted:

In a perfect world we wouldn't need to write code at all.

Was it in this thread that someone posted a story about his (possibly jock, definitely dumbass) brother thinking you could write a game by putting stuff like:
pre:
spawn world
spawn player
give player gun
spawn enemies
in a plain text file, and rename it to .exe to make a game? That story was hilarious.

FateFree
Nov 14, 2003

If I'm dealing with nearest neighbor pixel scaling, and I want to zoom in and out of say an overhead view, is there a certain factor i should 'snap' the scaling to every time, like when someone uses a mouse wheel? In other words, does nearest neighbor mean that I'll see a pixel perfect representation of a scaled sprite ALL the time, or only for certain scale factors? Obviously integer scaling like 2x and 3x work fine, but I'm talking about fractions of that (the smallest fraction that makes the sprite look perfect, if that makes sense).

DStecks
Feb 6, 2012

So, today I was reading Game Programming Patterns, and in its chapter on Singletons, he brings up that an issue with static variables is that it's impossible to know where they're being modified from; but couldn't this be pretty trivially solved by having the variables be static, but private, and accessed via (also static) getters and setters in the singleton? Because then you could drop a debug stop on the setter line. It seems so obvious it can't possibly work, right?

Edit: or in Visual Studio, just right click on the setter and select "show all references".

Obsurveyor
Jan 10, 2003

Anyone know much about Unity Mecanim retargeting animations? I've got an animation I'd like to use on a Humanoid that works fine on its original model but on anything else, it's like the feet switch positions.



Can't figure out how to fix it and it happens with every Humanoid setup I've thrown at it that isn't the original. I've confirmed that the Avatars for the original and the one I'm using here have the same bone assignments.

xezton
Jan 31, 2005


I can't answer your question, but I can definitely advise that you post that gif in this here thread: http://forums.somethingawful.com/showthread.php?threadid=3611075

Obsurveyor
Jan 10, 2003

xezton posted:

I can't answer your question, but I can definitely advise that you post that gif in this here thread: http://forums.somethingawful.com/showthread.php?threadid=3611075

Good idea, forgot about that thread.

Nude
Nov 16, 2014

I have no idea what I'm doing.

DStecks posted:

So, today I was reading Game Programming Patterns, and in its chapter on Singletons, he brings up that an issue with static variables is that it's impossible to know where they're being modified from; but couldn't this be pretty trivially solved by having the variables be static, but private, and accessed via (also static) getters and setters in the singleton? Because then you could drop a debug stop on the setter line. It seems so obvious it can't possibly work, right?

Edit: or in Visual Studio, just right click on the setter and select "show all references".

Not exactly sure what you're getting at, but I think what he means is:

Lets say you have a variable NumberOfEnemies being used with 10 different classes. And you have a glitch where NumberOfEnemies is 9 instead of 10, you have analyze one by one those 10 classes. I don't see how putting in a debug.log makes that any easier but maybe I'm missing something. IE: You could have an if statement in Class5 preventing it to ++, or Class3 only adds when the number is 4, etc etc.

Also I wouldn't ever put actual code in getters/setters (even debug). I just use them to declare private/public, but that might be just me. Putting code makes getters and setters more like methods instead of variables, but I think that is debatable for some people so take my advice with a grain of salt.

But of course the best way to find out any of this is to just do it anyway, and then go "oh that's why". That's mostly how I learn.

Nude fucked around with this message at 07:19 on Nov 21, 2015

From Earth
Oct 21, 2005

FateFree posted:

If I'm dealing with nearest neighbor pixel scaling, and I want to zoom in and out of say an overhead view, is there a certain factor i should 'snap' the scaling to every time, like when someone uses a mouse wheel? In other words, does nearest neighbor mean that I'll see a pixel perfect representation of a scaled sprite ALL the time, or only for certain scale factors? Obviously integer scaling like 2x and 3x work fine, but I'm talking about fractions of that (the smallest fraction that makes the sprite look perfect, if that makes sense).

It depends on what you're trying to draw and what range of zoom factors you're dealing with. Scaling usually looks best when using powers of two (so 2X, 4X, 8X), but keep in mind that nearest-neighbor scaling will always introduce aliasing. For visual quality, it's probably better to use something like linear filtering. Also, depending on how you're rendering things, you could use mipmaps to get decent results at scale factors that are not a power of two. Finally, zooming in further than the source image will always looks bad, so don't do it if you can avoid it.

Fano
Oct 20, 2010

Nude posted:

Also I wouldn't ever put actual code in getters/setters (even debug). I just use them to declare private/public, but that might be just me. Putting code makes getters and setters more like methods instead of variables, but I think that is debatable for some people so take my advice with a grain of salt.
That's kinda the point of properties in C# though, isn't it? It's mostly syntactic sugar for writing your own getter and setter methods, it allows you to perform validation or call events when your variables change without making sure that your clients call the right function, instead they assign your property and all the magic happens behind the scenes.

DStecks
Feb 6, 2012

Nude posted:

Lets say you have a variable NumberOfEnemies being used with 10 different classes. And you have a glitch where NumberOfEnemies is 9 instead of 10, you have analyze one by one those 10 classes. I don't see how putting in a debug.log makes that any easier but maybe I'm missing something. IE: You could have an if statement in Class5 preventing it to ++, or Class3 only adds when the number is 4, etc etc.

What makes it easier is that, at least in Unity, when you get a line in the Debug log you get the entire call stack that produced that line, telling you the exact class in which the error is happening.

Nude posted:

Also I wouldn't ever put actual code in getters/setters (even debug). I just use them to declare private/public, but that might be just me. Putting code makes getters and setters more like methods instead of variables, but I think that is debatable for some people so take my advice with a grain of salt.

If you aren't putting code in getters and setters, why are you even using them? If you refuse to put code in them, you gain nothing over just exposing the member variable. Like, I can sort of get it if the argument is that it's not super safe to put loads of executing code into a call that looks like simply accessing a variable, but putting a debug line into a getter or setter is, like, the exact reason you use them instead of just exposing the variable.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

DStecks posted:

If you aren't putting code in getters and setters, why are you even using them?
A pretty good reason is to do this:
code:
public int MyProperty { get; private set; }

DStecks
Feb 6, 2012

OneEightHundred posted:

A pretty good reason is to do this:
code:
public int MyProperty { get; private set; }

Ah, clever.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

ToxicSlurpee posted:

Interfaces are more of a software engineering thing when you have to deal with a lot of people working as a team.
This isn't really true. The main reason is to allow values of types to be passed to things that are only interested in a subset of that class's functionality, to allow a class to satisfy more than one of those subsets even if they're unrelated, and not have conflicting implementations.

A nice example of this would be that strings can be passed to foreach because String implements IEnumerable<char>, but they can also be inserted into ordered collections of strings because they implement IComparable<String>, two interfaces which are otherwise unrelated.

Manslaughter posted:

What do I do if I want a default behavior for my interface methods?
In C# 3.0 and above you can use extension methods.

code:
    public static class MyInterfaceExtensions
    {
        public static void DoSomething(this IMyInterface myInterface)
        {
            myInterface.DoSomething("asdf");
        }
    }

    public interface IMyInterface
    {
        void DoSomething(string s);
    }

    public class MyClass : IMyInterface
    {
        public void DoSomething(string s)
        {
            Console.WriteLine(s);
        }
    }

    public class Program
    {
        static void Main(string[] args)
        {
            IMyInterface myVar = new MyClass();
            myVar.DoSomething();
        }
    }

OneEightHundred fucked around with this message at 23:20 on Nov 21, 2015

thetroof
Jul 4, 2010

I think we got something here

Fano posted:

Pity that there don't seem to be many courses that focus on how to architect a game that is bigger in scope than your typical 'make your first game' tutorial, sometimes I feel that I am making a lot of stuff up as I build up my game and that there are probably some concepts/design standards that go into building the infrastructure for a game that I'm simply not aware of since I don't work in the industry.

Yeah, this can definitely be a tough thing to figure out. I think Game Engine Architecture by Jason Gregory gives a pretty good, if not slightly outdated, high-level picture of what goes into modern game engines. Here's a diagram from that book covering the different systems used in many modern games engines.

Obviously doing everything there would be overkill for smaller projects, but you can pick and choose what you need. I think it can also help to run through open sourced game engines to try and learn stuff (Quake 3 etc). Unfortunately I think the best primer is to go work at a company using a proprietary engine and be forced to learn how it works, which isn't really helpful advice for people doing game dev in their spare time.

xgalaxy
Jan 27, 2004
i write code
That Game Engine Architecture book is pretty good, and has a second edition now with some more up to date information.

DStecks
Feb 6, 2012

In Unity, why would resizing the scene view window corrupt my UI panels? I adjusted the size and suddenly two panels vanished, replaced with red wireframe x's.

dreamless
Dec 18, 2013



DStecks posted:

In Unity, why would resizing the scene view window corrupt my UI panels? I adjusted the size and suddenly two panels vanished, replaced with red wireframe x's.

That happens when anchoring gives things a negative size.

FateFree
Nov 14, 2003

Programming comes very natural to me, but coming up with ideas always gets me stumped. I want to build a settlement builder game with fighting mechanics, almost like a Link to the Past meets Prison Architect. But I find it very difficult to proceed without some sort of short term goals. I was wondering if you guys could spitball some ideas at me that I can run with.

My general idea is to have a bunch of settlers build a base, but also have the option to take control of someone or a group and venture out to find supplies, capture wildlife, etc. I liked the idea of the main base preparing for venturing out in the form of farming for food, training for combat, and defending etc.

What I'm looking for is any concrete goals I can start with. What can I do with a group of settlers do after plopping them in the middle of a map to make it feel like I'm playing a game? I'd appreciate any random ideas for game mechanics.

anatomi
Jan 31, 2015

You could order your settlers to Gather resources, combing the immediate surroundings for useful stuff. Assuming this is the beginning of the game and you're low on both manpower and tools, you're gonna need to set up some kind of camp. This seems like a logical place to start, I think. Do your settlers require Food/Water/Shelter/Sleep? If so, the most urgent task would be to satisfy their base needs.

Perhaps the earliest incarnation of your settlement takes the form of a nomadic tribe? Transition (or don't - maybe the environment is so volatile that you can't form a permanent settlement) into hunting, sowing wild oats, cultivation...

You could order your settlers to Build/Make stuff. Like setting up the aforementioned camp, or making tools to expedite various tasks, later on crafting items to trade.

You could order your settlers to Scout/Explore. Maybe the surrounding terrain is covered in a fog of war. Explorers will chart the terrain and highlight potential resources and interesting stuff like dungeons, ruins, landmarks. When Explorers return they'll fill in your map with their discoveries, but still leave out plenty of details for you to experience yourself. Maybe they come running home because they got hassled by another settlement or a monster or something. When you've got a settlement that can support your expeditions, maybe you could send Explorers to venture into said dungeons, or have them accompany the player.

Recruiting (how do you increase the number of your settlers? Is it dependent of the settlement size? Do settlers breed or does the player recruit them somehow? How is population controlled? Can your settlers die?)

Hope at least a couple of these make sense.

ShinAli
May 2, 2003

The Kid better watch his step.
Slightly off topic but still about game dev books, Artificial Intelligence for Games is a surprisingly good book about game AI that I've stayed away from due to its name. I've only got wind of it when an AI programmer directed me to it. It seems to be a good up-to-date look into part of game programming that seems to not have a lot of information for it exposed. Its like Game Engine Architecture but with pseudo-code examples.

FateFree
Nov 14, 2003

Thanks for the suggestions anatomi! Thats definitely what I'm looking for. I'll start with the food/water/shelter requirements. Thanks!

OzyMandrill
Aug 12, 2013

Look upon my words
and despair

DStecks posted:

So, today I was reading Game Programming Patterns, and in its chapter on Singletons, he brings up that an issue with static variables is that it's impossible to know where they're being modified from; but couldn't this be pretty trivially solved by having the variables be static, but private, and accessed via (also static) getters and setters in the singleton? Because then you could drop a debug stop on the setter line. It seems so obvious it can't possibly work, right?

Edit: or in Visual Studio, just right click on the setter and select "show all references".

Yes it can, but you have no control over when a static variable is instantiated, except that it happens before main() is called. Wrapping it in a singleton does the same as a static class with accessors, but it can be lazily constructed on first use, which can be guaranteed by you to be after you have created/loaded your world and objects in case the singleton wants to reference them. Not much point with a static var, and in Visual Studio you can set a break on write to an address if you need to track down a write coming via a badly computed pointer. The design pattern is more to get you to consider the way it protects from having more than one created, and use this on large unique class interfaces that you want just a single one of, but be globally accessible. Like a graphics engine interface, or your world data interface, or user settings that can be monolithically streamed to i/o.

You don't have to, it's just that doing it this way doesn't usually cost much (an extra if/branch per lookup) and can occasionally avoid the occasional subtle bug from initialisation ordering. At the very least let you do something about it by making sure important things get referenced in a certain order at the start. Of course you could have static objects and initialiser functions, then you have to remember to actually call all the initialisers, this way lets you get away with most of it being automatic based on first use, and occasionally you need to reference something earlier in your startup to ensure it exists in time.

DStecks
Feb 6, 2012

Screenshot saturday: Right-click context menus are now working (sort of):



They display properly, anyway. Options aren't being cleared from the list yet, but otherwise there's no way to show how it would look full. The buttons also aren't rigged up to do anything just yet.

DStecks
Feb 6, 2012

Today I learned that in C#, if you try to assign a value to a previously uninstantiated field, this will not instantiate it with the values you're trying to assign it, but will instantiate it as a reference to the value.

As in, this code:
code:
public Interaction(Interactable p_Parent, int p_Tag, List<int> p_AccessPoints)
    {
        m_Parent = p_Parent;
        m_Tag = p_Tag;

        m_AccessPoints = p_AccessPoints;
Was not instantiating m_AccessPoints as a new List<int> with the same contents as p_AccessPoints, but as a cached reference to p_AccessPoints, which the calling method immediately clears after calling this constructor. :v:

dupersaurus
Aug 1, 2012

Futurism was an art movement where dudes were all 'CARS ARE COOL AND THE PAST IS FOR CHUMPS. LET'S DRAW SOME CARS.'

DStecks posted:

Today I learned that in C#, if you try to assign a value to a previously uninstantiated field, this will not instantiate it with the values you're trying to assign it, but will instantiate it as a reference to the value.

As in, this code:
code:
public Interaction(Interactable p_Parent, int p_Tag, List<int> p_AccessPoints)
    {
        m_Parent = p_Parent;
        m_Tag = p_Tag;

        m_AccessPoints = p_AccessPoints;
Was not instantiating m_AccessPoints as a new List<int> with the same contents as p_AccessPoints, but as a cached reference to p_AccessPoints, which the calling method immediately clears after calling this constructor. :v:

Copy constructors are your friends

DStecks
Feb 6, 2012


That would be exactly the solution I used. :)

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

DStecks posted:

Today I learned that in C#, if you try to assign a value to a previously uninstantiated field, this will not instantiate it with the values you're trying to assign it, but will instantiate it as a reference to the value.

As in, this code:
code:
public Interaction(Interactable p_Parent, int p_Tag, List<int> p_AccessPoints)
    {
        m_Parent = p_Parent;
        m_Tag = p_Tag;

        m_AccessPoints = p_AccessPoints;
Was not instantiating m_AccessPoints as a new List<int> with the same contents as p_AccessPoints, but as a cached reference to p_AccessPoints, which the calling method immediately clears after calling this constructor. :v:

Thank god it doesn't or there'd be no way to access references. I don't think there are any languages that behave that way because it makes no sense. If you want to make a copy, make a copy. I don't want implicit copies by reference, oh god no.

evilentity
Jun 25, 2010

DStecks posted:

Today I learned that in C#, if you try to assign a value to a previously uninstantiated field, this will not instantiate it with the values you're trying to assign it, but will instantiate it as a reference to the value.

As in, this code:
code:
public Interaction(Interactable p_Parent, int p_Tag, List<int> p_AccessPoints)
    {
        m_Parent = p_Parent;
        m_Tag = p_Tag;

        m_AccessPoints = p_AccessPoints;
Was not instantiating m_AccessPoints as a new List<int> with the same contents as p_AccessPoints, but as a cached reference to p_AccessPoints, which the calling method immediately clears after calling this constructor. :v:

In what language would that be the case? You could probably get it to work in C++ with op overloading i guess.

josh04
Oct 19, 2008


"THE FLASH IS THE REASON
TO RACE TO THE THEATRES"

This title contains sponsored content.

std::vector works that way in C++ afaik.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.
You'd need an overloaded copy constructor. He clearly comes from C++ with the Hungarian Notation, and C++ does call the copy constructor on assignment; but most other languages do not. With C# and Java you need to call new(...) explicitly to use the copy constructor.

Adbot
ADBOT LOVES YOU

DStecks
Feb 6, 2012

Yeah, my primary education was with C++, where I vaguely remember that having worked.

I also had not coded anything in any language in nearly 3 years before starting this project, with only 2 years of college education. :v:

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply