As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
Options

Game Dev - Unreal 4.13 Out Now!

16566687071100

Posts

  • Options
    David_TDavid_T A fashion yes-man is no good to me. Copenhagen, DenmarkRegistered User regular
    Huh. I may need some help on this trading model.

    I mean, it's horribly simple right now. There are ten commodities that have a base price. Not every town has every commodity in stock, most have between two to four of them.

    Right now I have it set up so if a town does not have a commodity, it will buy one unit of it from you for the base price.

    If the town does have it, the price is whatever is highest of the base price minus (the amount of stock divided by two) or the base price divided by ten.

    Meanwhile, the price for you to buy from the town is the base price with a bonus of (25 minus the amount of stock), but no lower what the town will pay you. 25 was a number pulled out of a hat, basically.

    Now, what that does is give some amount of leeway for trading, it is possible to buy goods for less than you will then get for them when you sell them at the next town, but it's fairly static in that if the stock is over 25, you'll pay less than the base price and if it's under, you'll pay more. So unless the stock is 26 or above, there's really no reason for you to trade.

    I have a territory system set up and I'm planning on having some goods be more in demand in certain territories and easier to come by in others, but apart from that, is there anything I can do to make the whole thing feel a bit more dynamic?

    Oh, I also have it set up so at somewhat random intervals, some stocks will either go up or down. So there's some degree of market movement without you.

    On the plus side, combat is hooked up and upgrade path is halfway done. I'm very close to having something that's full of gameplay systems if not actual content.

    euj90n71sojo.png
  • Options
    LaCabraLaCabra MelbourneRegistered User regular
    Hey who'd be interested in a tutorial along the lines of like, here's how to create a proto this-type-of-game, from scratch in Blueprint. Like a racer or something maybe

  • Options
    GlalGlal AiredaleRegistered User regular
    As someone who finds tutorials a million times quicker to digest than reading documentation pages, very yes.

  • Options
    LaCabraLaCabra MelbourneRegistered User regular
    What kinda thing'd be good

  • Options
    GlalGlal AiredaleRegistered User regular
    Anything that demonstrates the logic behind Blueprints and provides examples of its components and what they are for/what they can do. Bonus points for any sort of Best Practice tips, so newbies don't have to learn from their own failures on how to make legible and maintainable "code". Oh, and gotchas, those are always fun (ie, "crap, why is it all black?").

  • Options
    LaCabraLaCabra MelbourneRegistered User regular
    I feel like I'd probs be alright at that. Maybe a cart racer or somethin'. Bleep bloop.

  • Options
    KashaarKashaar Low OrbitRegistered User regular
    ITT: Joe wants to make a racing game and is looking for justification :D

    Indie Dev Blog | Twitter | Steam
    Unreal Engine 4 Developers Community.

    I'm working on a cute little video game! Here's a link for you.
  • Options
    LaCabraLaCabra MelbourneRegistered User regular
    brah plz do i seem like a dude who needs justification to start yet another video game

  • Options
    MahnmutMahnmut Registered User regular
    edited August 2015
    Glal wrote: »
    Anything that demonstrates the logic behind Blueprints and provides examples of its components and what they are for/what they can do. Bonus points for any sort of Best Practice tips, so newbies don't have to learn from their own failures on how to make legible and maintainable "code". Oh, and gotchas, those are always fun (ie, "crap, why is it all black?").

    It might be good to highlight the nodes that make really good use of the unique Event Graph concept -- specifically I have in mind timelines, which I think are the best Blueprint feature. And also it's just awesome that you're thinking of adding to the Unreal Engine knowledge-base. <3

    Mahnmut on
    Steam/LoL: Jericho89
  • Options
    DiamondGFXDiamondGFX Registered User regular
    @MNC Dover I'd be happy to critique the game when it's done. Just let me know.

    I'm also more of a tutorial sort of person and I love the "create X type of game in Y" style tutorials as well. I always learn much better from practical applications instead of "here's how you do (random disjointed effect)" because having the full picture there allows me to piece details together better.

    ain't got one
  • Options
    Xavier1216Xavier1216 Bagu is my name. Show my note to river man. Greater Boston AreaRegistered User regular
    edited August 2015
    DiamondGFX wrote: »
    MNC Dover I'd be happy to critique the game when it's done. Just let me know.

    I'm also more of a tutorial sort of person and I love the "create X type of game in Y" style tutorials as well. I always learn much better from practical applications instead of "here's how you do (random disjointed effect)" because having the full picture there allows me to piece details together better.

    I'm definitely in the camp for this style of tutorial, as well. Plus, after piecing together the current lesson or project for that tutorial, I always get curious about adding extra features or tweaking the lesson to learn more on my own.

    Also, @MNC Dover, I'd be happy to help you out with your promo video.

    Xavier1216 on
    SMMB_Xavier1216_Large_zpscdweorm9.png
    PSN: PLD_Xavier | NNID: Xavier1216
  • Options
    KupotheAvengerKupotheAvenger Destroyer of Cake and other deserts.Registered User regular
    Idea/question. Do you guys know how difficult it would be to program a game similar to fantasy life? Potentially on the unreal engine? Suggestions on what engine one would use for a cutesy diablo-esque style game?

    fc: 1821-9801-1163
    Battlenet: Judgement#1243
    psn: KupoZero

  • Options
    MNC DoverMNC Dover Full-time Voice Actor Kirkland, WARegistered User regular
    Awesome guys. I'll try and get the video cranked out this weekend.

    Need a voice actor? Hire me at bengrayVO.com
    Legends of Runeterra: MNCdover #moc
    Switch ID: MNC Dover SW-1154-3107-1051
    Steam ID
    Twitch Page
  • Options
    AntinumericAntinumeric Registered User regular
    Ok I've hit a silly problem. I'm using C# to make a game for the first time without Unity. However, I didn't realise I can't use a global variable for my game manager class. I don't exactly want to pass around a map/player object to every single method that might use it, and the singleton pattern looks like useless busywork compared to just having a global variable. And I'm not sure but it might have some instantiation issues relating to it being static.

    Is this really the route I have to go? Or am I doing it wrong?

    In this moment, I am euphoric. Not because of any phony god’s blessing. But because, I am enlightened by my intelligence.
  • Options
    LaCabraLaCabra MelbourneRegistered User regular
    are you vid tute guys or text tute guys

  • Options
    AntinumericAntinumeric Registered User regular
    LaCabra wrote: »
    are you vid tute guys or text tute guys
    Vid if you speak reasonably quickly and have an okay or better voice. Text otherwise.

    In this moment, I am euphoric. Not because of any phony god’s blessing. But because, I am enlightened by my intelligence.
  • Options
    GarthorGarthor Registered User regular
    Ok I've hit a silly problem. I'm using C# to make a game for the first time without Unity. However, I didn't realise I can't use a global variable for my game manager class. I don't exactly want to pass around a map/player object to every single method that might use it, and the singleton pattern looks like useless busywork compared to just having a global variable. And I'm not sure but it might have some instantiation issues relating to it being static.

    Is this really the route I have to go? Or am I doing it wrong?

    Singleton pattern is the way you want to go and there's really isn't all that much busywork. Singletons aren't supposed to be static, just have a static class variable pointing to it (so, for instance, GameManager.Instance gets you the singleton instance, and so is static, but the class itself is not).

  • Options
    LorkLork Registered User regular
    edited August 2015
    Ok I've hit a silly problem. I'm using C# to make a game for the first time without Unity. However, I didn't realise I can't use a global variable for my game manager class. I don't exactly want to pass around a map/player object to every single method that might use it, and the singleton pattern looks like useless busywork compared to just having a global variable. And I'm not sure but it might have some instantiation issues relating to it being static.

    Is this really the route I have to go? Or am I doing it wrong?
    Singletons should have a static reference to themselves that gets set on initialization, like this:
    public class GameManager
    {
    	public static GameManager self;
            public int myVariable;
    
            public GameManager()
            {
                if(self == null)
                    self = this;
            }
    }
    

    Then when you want to access the variable you can just do "GameManager.self.myVariable" from anywhere.

    Edit: Actually, I didn't see that you said you're doing it without Unity, so here's a less Unity-fied version.

    Lork on
    Steam Profile: Lork
  • Options
    KupiKupi Registered User regular
    Maybe it's just me approaching the exercise badly, but I've often been frustrated by tutorials that just pour you through the steps without keeping you informed as to you why exactly you're doing what you're doing. The UE4 manual's how-tos have been kind of bad about that, in my experience; they tell you to make four of this kind of node, two of another, and hook this thing into that thing, and type this series of numbers into those textboxes, and hooray! We have a scene that demonstrates the engine's realistic lighting model! And after made all the nodes and hooking the connectors together and typing all the numbers into the textboxes, I have that demonstration running on my machine but damned if I understood any of the principles behind it well enough to replicate it on my own, or in novel configurations... in which case the article has sort of failed as a tutorial. (Though again, I'll also cop to not engaging as fully as I should.)

    My favorite musical instrument is the air-raid siren.
  • Options
    AntinumericAntinumeric Registered User regular
    edited August 2015
    Lork wrote: »
    Ok I've hit a silly problem. I'm using C# to make a game for the first time without Unity. However, I didn't realise I can't use a global variable for my game manager class. I don't exactly want to pass around a map/player object to every single method that might use it, and the singleton pattern looks like useless busywork compared to just having a global variable. And I'm not sure but it might have some instantiation issues relating to it being static.

    Is this really the route I have to go? Or am I doing it wrong?
    Singletons should have a static reference to themselves that gets set on initialization, like this:
    public class GameManager
    {
    	public static GameManager self;
            public int myVariable;
    
            public GameManager()
            {
                if(self == null)
                    self = this;
            }
    }
    

    Then when you want to access the variable you can just do "GameManager.self.myVariable" from anywhere.

    Edit: Actually, I didn't see that you said you're doing it without Unity, so here's a less Unity-fied version.
    Yeah I dived in with it and it works fine. A few problems tho, anything set in its constructor cannot reference any other methods it contains. Otherwise it's working great!

    Here's the output:
    IoYFIkK.png

    Pretty unimpressive but it's working out the contents of each tile by asking it if it has any renderables in it, then rendering the one with the highest priority.

    And some prototyping I've been doing:
    qCCW9Sr.png
    ty7ErBM.png

    Antinumeric on
    In this moment, I am euphoric. Not because of any phony god’s blessing. But because, I am enlightened by my intelligence.
  • Options
    LorkLork Registered User regular
    Lork wrote: »
    Ok I've hit a silly problem. I'm using C# to make a game for the first time without Unity. However, I didn't realise I can't use a global variable for my game manager class. I don't exactly want to pass around a map/player object to every single method that might use it, and the singleton pattern looks like useless busywork compared to just having a global variable. And I'm not sure but it might have some instantiation issues relating to it being static.

    Is this really the route I have to go? Or am I doing it wrong?
    Singletons should have a static reference to themselves that gets set on initialization, like this:
    public class GameManager
    {
    	public static GameManager self;
            public int myVariable;
    
            public GameManager()
            {
                if(self == null)
                    self = this;
            }
    }
    

    Then when you want to access the variable you can just do "GameManager.self.myVariable" from anywhere.

    Edit: Actually, I didn't see that you said you're doing it without Unity, so here's a less Unity-fied version.
    Yeah I dived in with it and it works fine. A few problems tho, anything set in its constructor cannot reference any other methods it contains. Otherwise it's working great!
    I'm not completely sure what you're referring to here. Constructors should be able to access other members of the class, including methods - they'd be pretty useless if they couldn't. What you may be running in to is trying to reference non static members without a reference. Eg. "GameManager.MyNonStaticMethod()", which doesn't work because you're not specifying which specific instance of the class will run the method. Luckily the "self" reference we set up can handle that, so "GameManager.self.MyNonStaticMethod()" should work.

    Steam Profile: Lork
  • Options
    LaCabraLaCabra MelbourneRegistered User regular
    LaCabra wrote: »
    are you vid tute guys or text tute guys
    Vid if you speak reasonably quickly and have an okay or better voice. Text otherwise.
    maybe holla at one of the videos i've posted in the last few pages? i actually got a lot of talking-too-fast-complaints on the last one but i could slow up, and also those were scripted

  • Options
    MNC DoverMNC Dover Full-time Voice Actor Kirkland, WARegistered User regular
    Why wait for the weekend, when you can power out the video tonight?

    https://www.dropbox.com/s/joa4t9hgw5dpre3/promoVideo_1.mp4?dl=0

    Let me know what you guys think. It's mostly complete and I don't want to overhaul it too much, but I'll gladly accept all critiques. :)

    Need a voice actor? Hire me at bengrayVO.com
    Legends of Runeterra: MNCdover #moc
    Switch ID: MNC Dover SW-1154-3107-1051
    Steam ID
    Twitch Page
  • Options
    surrealitychecksurrealitycheck lonely, but not unloved dreaming of faulty keys and latchesRegistered User regular
    LaCabra wrote: »
    I feel like I'd probs be alright at that. Maybe a cart racer or somethin'. Bleep bloop.

    if ur aiming at totes new beginners really important stuff would be:

    -highlighting the blueprint context menus for referring to specific objects and stuff
    -talking about when to cast / why casting is important (this is the one that makes the least sense to people who dont program)
    -getting the basic flow control stuff in (branch/flipflop/foreach)
    -referring to blueprints from each other
    -THE CONTROLLER/PRAWN SPLIT! poor little prawns...

    obF2Wuw.png
  • Options
    GlalGlal AiredaleRegistered User regular
    LaCabra wrote: »
    LaCabra wrote: »
    are you vid tute guys or text tute guys
    Vid if you speak reasonably quickly and have an okay or better voice. Text otherwise.
    maybe holla at one of the videos i've posted in the last few pages? i actually got a lot of talking-too-fast-complaints on the last one but i could slow up, and also those were scripted
    I think your voice is just fine! And I'm the type of person that normally gets thrown off by tutorials with odd speech/accents.

  • Options
    amnesiasoftamnesiasoft Thick Creamy Furry Registered User regular
    Text + Pictures > Video.

    It's significantly easier to navigate around with text. It's also a lot easier to follow along at your own pace.

    steam_sig.png
  • Options
    AntinumericAntinumeric Registered User regular
    edited August 2015
    Lork wrote: »
    Lork wrote: »
    Ok I've hit a silly problem. I'm using C# to make a game for the first time without Unity. However, I didn't realise I can't use a global variable for my game manager class. I don't exactly want to pass around a map/player object to every single method that might use it, and the singleton pattern looks like useless busywork compared to just having a global variable. And I'm not sure but it might have some instantiation issues relating to it being static.

    Is this really the route I have to go? Or am I doing it wrong?
    Singletons should have a static reference to themselves that gets set on initialization, like this:
    public class GameManager
    {
    	public static GameManager self;
            public int myVariable;
    
            public GameManager()
            {
                if(self == null)
                    self = this;
            }
    }
    

    Then when you want to access the variable you can just do "GameManager.self.myVariable" from anywhere.

    Edit: Actually, I didn't see that you said you're doing it without Unity, so here's a less Unity-fied version.
    Yeah I dived in with it and it works fine. A few problems tho, anything set in its constructor cannot reference any other methods it contains. Otherwise it's working great!
    I'm not completely sure what you're referring to here. Constructors should be able to access other members of the class, including methods - they'd be pretty useless if they couldn't. What you may be running in to is trying to reference non static members without a reference. Eg. "GameManager.MyNonStaticMethod()", which doesn't work because you're not specifying which specific instance of the class will run the method. Luckily the "self" reference we set up can handle that, so "GameManager.self.MyNonStaticMethod()" should work.
    I was doing it a different way. Something like
    class GameManager
    {
        public static GameManager instance = new GameManager();
        private GameManager()
        {
            map.initialise();
        }
    }
    
    map.initialise()
    {
        Tile t = new Tile();
        t.Add(GameManager.instance.CreateObject("Wall"); //<--------- Error Here
    }
    
    I solved it by creating an initialise function to make the map after the constructor.
    Your method has to create a GameManager at some point, but it makes construction and flow easier. Thanks!


    LaCabra wrote: »
    I feel like I'd probs be alright at that. Maybe a cart racer or somethin'. Bleep bloop.

    if ur aiming at totes new beginners really important stuff would be:

    -highlighting the blueprint context menus for referring to specific objects and stuff
    -talking about when to cast / why casting is important (this is the one that makes the least sense to people who dont program)
    -getting the basic flow control stuff in (branch/flipflop/foreach)
    -referring to blueprints from each other
    -THE CONTROLLER/PRAWN SPLIT! poor little prawns...
    The controller pawn split is really weird. Several of their examples contradict each other on which should have what functionality and asking questions on the answerhub gave conflicting answers yet again.
    LaCabra wrote: »
    LaCabra wrote: »
    are you vid tute guys or text tute guys
    Vid if you speak reasonably quickly and have an okay or better voice. Text otherwise.
    maybe holla at one of the videos i've posted in the last few pages? i actually got a lot of talking-too-fast-complaints on the last one but i could slow up, and also those were scripted
    Your voice is great! Go for it!

    Antinumeric on
    In this moment, I am euphoric. Not because of any phony god’s blessing. But because, I am enlightened by my intelligence.
  • Options
    KashaarKashaar Low OrbitRegistered User regular
    LaCabra wrote: »
    I feel like I'd probs be alright at that. Maybe a cart racer or somethin'. Bleep bloop.

    if ur aiming at totes new beginners really important stuff would be:

    -highlighting the blueprint context menus for referring to specific objects and stuff
    -talking about when to cast / why casting is important (this is the one that makes the least sense to people who dont program)
    -getting the basic flow control stuff in (branch/flipflop/foreach)
    -referring to blueprints from each other
    -THE CONTROLLER/PRAWN SPLIT! poor little prawns...
    The controller pawn split is really weird. Several of their examples contradict each other on which should have what functionality and asking questions on the answerhub gave conflicting answers yet again.

    I like to think it's a nice thing that it doesn't force you to do stuff one way only. Hell, you could handle all your input in the level blueprint if you were so inclined (and stupid enough to think that would be a good idea).

    The way I've always thought of it: The controller is the abstract representation of the player in front of the computer. Pawns are puppets on strings, and controllers are those wooden cross things that the strings are attached to, while players are the puppet masters moving the cross.

    No, actually they're more like the forces exerted by the hand on the cross - since different kinds of puppets will have different crosses.

    Sooo in more concrete terms, pawns are the characters within the world, and controllers are what give them instructions. Depending on the structure of a game, you could have your whole input logic handled within a pawn, or you could build a controller-agnostic pawn that can be controlled equally well by players and AI, and handle the player input for it in the player controller. Or you could have a game where you switch between different pawns (e.g. moving around as a person on foot or as a car. Or you could have a game where a single player controls multiple pawns.

    Anyway, using this properly is a lot more relevant in multiplayer, and doesn't matter so much if you don't do something that's going to be networked.

    Indie Dev Blog | Twitter | Steam
    Unreal Engine 4 Developers Community.

    I'm working on a cute little video game! Here's a link for you.
  • Options
    Xavier1216Xavier1216 Bagu is my name. Show my note to river man. Greater Boston AreaRegistered User regular
    @MNC Dover, I'm sold. The music is bouncy, everything looks clean, and the scene transitions are smooth. It's a very professional-looking video, and a very fun-looking game.

    If I had to give one critique, I would say it would be the intro description of the game. I may just be slow this morning, but I had to re-watch the first level example a couple of times to understand the goal of the game. Instead of "Mix colors to solve puzzles!", I would try to explicitly state that you're doing it to match the on-screen example. It became obvious eventually, but a promo doesn't always have the benefit of being re-watched.

    Any plans for Android release? Or maybe 3DS/console?

    SMMB_Xavier1216_Large_zpscdweorm9.png
    PSN: PLD_Xavier | NNID: Xavier1216
  • Options
    MNC DoverMNC Dover Full-time Voice Actor Kirkland, WARegistered User regular
    Xavier1216 wrote: »
    @MNC Dover, I'm sold. The music is bouncy, everything looks clean, and the scene transitions are smooth. It's a very professional-looking video, and a very fun-looking game.

    If I had to give one critique, I would say it would be the intro description of the game. I may just be slow this morning, but I had to re-watch the first level example a couple of times to understand the goal of the game. Instead of "Mix colors to solve puzzles!", I would try to explicitly state that you're doing it to match the on-screen example. It became obvious eventually, but a promo doesn't always have the benefit of being re-watched.

    Any plans for Android release? Or maybe 3DS/console?

    How about something like "mix colors to match the target board". Ugh, that just sounds too stiff and over explained. Needs to be punchy yet informative.

    Need a voice actor? Hire me at bengrayVO.com
    Legends of Runeterra: MNCdover #moc
    Switch ID: MNC Dover SW-1154-3107-1051
    Steam ID
    Twitch Page
  • Options
    Xavier1216Xavier1216 Bagu is my name. Show my note to river man. Greater Boston AreaRegistered User regular
    edited August 2015
    "Mix colors to match the pattern"? That might be too much, too. Hmm... maybe you already had the best one.

    Sorry if I'm not being very helpful. It's a nitpick, really, so don't worry about it.

    Xavier1216 on
    SMMB_Xavier1216_Large_zpscdweorm9.png
    PSN: PLD_Xavier | NNID: Xavier1216
  • Options
    DiamondGFXDiamondGFX Registered User regular
    @MNC Dover That looks pretty great! It looks like the sort of game that will get a lot of play in my wife's family especially, so I'll pass its existence along to them. Music is upbeat but not irritating, and the concept looks pretty fun, although I get the impression that the later levels may be a wee bit on the frustrating side (entirely in a good way). Good job!

    Also, text tutorials over video tutorials all the way. There's nothing more frustrating than "okay, I'm just going to follow along here and ...wait, what did that person say? Weird, I'm getting different results...*rewind* *repeat ad nauseum*"

    ain't got one
  • Options
    MNC DoverMNC Dover Full-time Voice Actor Kirkland, WARegistered User regular
    There's 3 different songs to choose from in the game, all unique and fitting. The later stages can get pretty tough for sure. Hell, I made them and get stuck sometimes. :)

    The game offers the first two worlds for free and 4 levels of each new world so the player can experience every mechanic. Totals out to 52 free levels, with the rest as paid unlockable content at $.99.

    I forgot to mention that an android version is definitely being considered...as long as the game sells enough to warrant the time. 3ds and consoles are probably out as they will probably not be profitable and the audience not in-line with this type of game.

    Need a voice actor? Hire me at bengrayVO.com
    Legends of Runeterra: MNCdover #moc
    Switch ID: MNC Dover SW-1154-3107-1051
    Steam ID
    Twitch Page
  • Options
    KhavallKhavall British ColumbiaRegistered User regular
    I really, really, really, really, really, really really wish Epic would spend just a little bit of time updating their tutorials. Even just links added to the videos saying "Hey in 4.8 you need to change your header and include a constructor for reasons".

    The lack of documentation compared to Unity is staggering, and it makes everything to do with Unreal a frustrating mess.

  • Options
    AkimboEGAkimboEG Mr. Fancypants Wears very fine pants indeedRegistered User regular
    Give me a kiss to build a dream on; And my imagination will thrive upon that kiss; Sweetheart, I ask no more than this; A kiss to build a dream on
  • Options
    David_TDavid_T A fashion yes-man is no good to me. Copenhagen, DenmarkRegistered User regular
    Okay, I have an alpha version of what I've been working on if anyone wants to try it out.

    It's basically Sunless Sea meets Mad Max. Top down open world wasteland, drive around, trade goods, buy new cars and weapons, get into fights. It's really ugly, because I suck at art, and there's not much there content-wise, but the core gameplay mechanics are in. Controls with arrow keys and mouse, sometimes enter, escape and M (for Map).

    euj90n71sojo.png
  • Options
    KhavallKhavall British ColumbiaRegistered User regular
    I think finally

    After months of pulling my hair out and hating everything.

    I think I'm finally where I wanted to be 4 months ago in terms of understanding and being able to use Unreal for development. Just in time to take a 2-week relax+recharge time and start actually having to do stuff.

  • Options
    rembrandtqeinsteinrembrandtqeinstein Registered User regular
    Garthor wrote: »
    Ok I've hit a silly problem. I'm using C# to make a game for the first time without Unity. However, I didn't realise I can't use a global variable for my game manager class. I don't exactly want to pass around a map/player object to every single method that might use it, and the singleton pattern looks like useless busywork compared to just having a global variable. And I'm not sure but it might have some instantiation issues relating to it being static.

    Is this really the route I have to go? Or am I doing it wrong?

    Singleton pattern is the way you want to go and there's really isn't all that much busywork. Singletons aren't supposed to be static, just have a static class variable pointing to it (so, for instance, GameManager.Instance gets you the singleton instance, and so is static, but the class itself is not).

    I guess I need to go back to school. I looked up singleton vs static and after several pages extolling the virtues of singleton over static I'm still not convinced.

    I have "stuff" that I want only 1 copy of and I want accessible by anything. Why is Foo.instance.stuffIWant better than just Foo.stuffIWant?

    In game programming terms the only practical concern I can think of is you need to would need to remember to reset all of your static properties whenever your game loop repeats (score, player name, etc) otherwise you would use the old values. But using a singleton isn't fundamentally different since instead of a static "initialize" method you would be putting that into the constructor.

    Can someone explain in more detail, preferably with some use cases?

  • Options
    David_TDavid_T A fashion yes-man is no good to me. Copenhagen, DenmarkRegistered User regular
    Well, this is weird.

    In Gamemaker Studio I have an object that creates another object and assigns it a bunch of variables.

    I also have a draw event that says "if this object exists and the variable telling me it's ok to read from the object is true, draw the variables from that object to the screen".

    Create object code reads
    fighter1 = instance_create(-10, -10, obj_fighter)
    fighter1.name = menu_fighter_name;
    fighter1_name = fighter1.name
    

    menu_fighter_name is a variable from a keyboard string. I've assigned the name both to the object and also from the object to a local variable for troubleshooting.

    Now, if the draw event draws fighter1.name to the screen, I get an error message saying that it couldn't get the fighter1.name variable. If the draw event draws fighter1_name, which is taken from the variable fighter1.name, it draws the name I wrote. So the draw event can't access fighter1.name, but the step event can? I don't get it.

    euj90n71sojo.png
  • Options
    GarthorGarthor Registered User regular
    Garthor wrote: »
    Ok I've hit a silly problem. I'm using C# to make a game for the first time without Unity. However, I didn't realise I can't use a global variable for my game manager class. I don't exactly want to pass around a map/player object to every single method that might use it, and the singleton pattern looks like useless busywork compared to just having a global variable. And I'm not sure but it might have some instantiation issues relating to it being static.

    Is this really the route I have to go? Or am I doing it wrong?

    Singleton pattern is the way you want to go and there's really isn't all that much busywork. Singletons aren't supposed to be static, just have a static class variable pointing to it (so, for instance, GameManager.Instance gets you the singleton instance, and so is static, but the class itself is not).

    I guess I need to go back to school. I looked up singleton vs static and after several pages extolling the virtues of singleton over static I'm still not convinced.

    I have "stuff" that I want only 1 copy of and I want accessible by anything. Why is Foo.instance.stuffIWant better than just Foo.stuffIWant?

    In game programming terms the only practical concern I can think of is you need to would need to remember to reset all of your static properties whenever your game loop repeats (score, player name, etc) otherwise you would use the old values. But using a singleton isn't fundamentally different since instead of a static "initialize" method you would be putting that into the constructor.

    Can someone explain in more detail, preferably with some use cases?

    Singletons are objects, which allows you to use various object-oriented principles such as inheritance and polymorphism. It also can be passed as a parameter which might be useful when working with external libraries.

    If you search for "singleton vs. static" on Google you'll get a bunch of articles about this and they all seem to be copy-pasted from each other. This is an example of poor object-oriented practices and there should instead be a super-article that they all derive from.

Sign In or Register to comment.