• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

160 Neutral

About 3dmodelerguy

  • Rank

Personal Information

  • Interests
  1. So I am building a survival / roguelike? (not sure of the "real" definition of that but the game has perma-death, randomly / procedurally generated worlds, etc.) and I am starting to prototype item decay. Let me example how the turn based system is currently simulated as that is probably important for this discussion. The way the turn based simulation works is there is a singleton GameActionManager object that keeps track of the action units that have pasted since the being of the game. 1 action unit = 1 second in the game and generally this is progressed from the the player performing an action. When the player does anything that has an action unit cost associated with it, it calls a method on the GameActionManager to increase the current action units. The other things the GameActionManager exposes are methods to register / unregister "event listeners" (currently using delegates). When the GameActionManager increases the action units, it notifies all of these listeners so the can perform the right action (like a burning tile decreasing the health of the structure that is burning, an enemy can move toward or attack something, etc.). I am also only simulating a small portion of the world at a given time since well, the world eventually will be huge and well computers can only do so much. My current goal for the simulated area is 120 x 80 tiles (with is a total of 9600 tiles). So as the player moves, game entities (enemies, structures, items, etc.) come in and out of the simulation area (and register / unregister with the GameActionManager). With this size in mind, none of the things that currently attach listeners to the GameActionManager has the chance of getting big enough to have me think that I really need to think about an alternative solution for when it becomes an issue because I don't see it becoming an issue any time soon (at least at the current stage of development). Items however is a different story. The game is going to have a ton of different items and 1 or more items can be on any tile. If each tile averaged 2.5 items (which I will grant you seem ridiculous but I always think crazy extremes when it comes to this kind of thing), that would be close for 25000 items that would possible have to manage decay. So instead of having each item attach a "listener", since the action for managing decay is going to be exactly the same thing for each item (just a method call), I figured having 1 listener that knows about all the items would be better. The general approach that I am taking for this first prototype is to have a singleton manager class (lets call it ItemDecayManager). Any time a item that has decay come into the simulated area, it would register itself with the manager and when it leaves the simulated area, it would unregister itself (which would just add and remove itself from a private List the manager is maintaining). Any time the action units are increased, the ItemDecayManager's listener on the would fire and just loop through the List of registered item and just perform the required function call. I have done some crude benchmarking and it currently can handle 100000 items at which point it starts to have a little effect on the FPS (but still around 80) even when moving about 15 times per second (and each move causes an action unit increase). Also bear in mind these numbers of from running the game in the Unity editor which has a bit of extra overhead that running the real game build not not have. While I am going to run with this solution for now I want to throw out this idea and get any kind of feedback i can because I imagine when more is happen as the action units increase (and even imagining the process for managing decay become more even just slight more complex than the current simple calculation), this solution might not hold up and I would like to have so ideas ready for the situations. I also think of anything that is going to be simulation, this is going to be the first things to have issues from the shear number of items that could be in the simulation area. Thanks in advance for any and all comments.
  2. Starting A Game Development Video Series

    Part 6: https://youtu.be/U-0j2AChz9Q
  3. @Kirlim Thanks for the feedback, let me respond. I absolutely agree with that and my original post was trying to explain that as my general original idea (I used bad wording in using behaviour to mean general functionality and not MonoBehaviour). Also thinking about this more, I am going to need to be able to have destructible tiles that don't have colliders on them too so something like this I think is going to be needed no matter what. I have not had much issue with using colliders but then again I might be using it in a non-standard way. I am not using it for physics or anything like that as all movement is just manual position manipulation. What I am using colliders to be able to raycast to detect what objects are in a particular location. I would like to avoid creating my own collision system unless 100% needed. I am using Unity in order to not have to create those lower / mid level game engine systems that I don't have an interest in building nor do I believe I have the technical knowledge required to build them in any meaningful or efficient way. While I can't say for sure, I think they are (and by needed, I mean they are much easier to work with that other alternatives). For one, the path finding solution I am using makes it calculations based on colliders to know where impassable areas are. Another case where I think they are very useful is for tracking enemies. Without colliders I would have to have an array of all enemies and where they are and such but seems like a bit of data to manage manually (not to mention they are accounted for in the path finding). I am making a number of assumptions and I am willing to consider other ideas however one thing I don't want to do is reinvent solutions in which I don't need a unique solution. Building a custom collision system seems like a bit of work and I can't imagine any custom work I would need that Unity's collision system does not have. It also seems like building a custom collision system before the Unity's collision system is giving me problems might be a bit premature. Building a path finding solution is pretty much the same. The path finding I am going to need for this game is relatively basic in comparison to what other game might need to have. I hoped I am not coming off as "I don't want to do any programming and just have a create game button for me" too much but I am using Unity because I don't want to deal with all the lower level stuff and be able to focus the unique parts of my game as much as possible. I understand there are going to be some lower level stuff I might have to build but I don't think the collision system is really giving me any issue right now.
  4. @flodihn Yea, I know premature optimization is the root of all evil but that does not mean you should always just write whatever unoptimized code first pops in your head. Over planning is generally not a good thing but under planning can be just as bad. The reason each tile needs it own MonoBehaviour instance (though in reality, I could probably just use a regular Class) it that each tile should have it own set of data. For example, one type of destruction would be fire. One tile catches fire and then each turn a percentage of the structure's HP (for lack of a better term) is decreased and the tiles next to it have a chance to also catch on fire which just repeats the process until either no tiles nearby can be caught on fire or the fire stops for whatever reason on all tiles. I don't see how I would be able to have this kinda of functionality without each tile having it own set of data (but maybe there are ways) Another reason I failed to mention originally for that array structure is that I am going to need something like this anyways. The map is ultimately going to be generated procedurally and I am going to need to save the maps data out anyways including this data (so that If I save the game and a building is on fire, that same building should be on fire when I load it back up).
  5. @Spool My concern is that I still want to able to to render 4500 - 5000 tiles at any given time and there could easily be time where there are anywhere from 1000 - 3000 destructible tiles and having that many colliders active at one time I would think would be a bit much (though I am pretty new to game dev so not sure). @AlbertoFdzM No, I am using Super Tilemap Editor though it has similar functionality but I concern above applies to doing that.
  6. Starting A Game Development Video Series

    Part 5: https://youtu.be/Q3dz3MmFWho
  7. So I am building a turn based rogue-like (think CDDA). The game is going to have a very large map (up to 1000's x 1000's) however to alleviate most of that I obviously can't render everything so there will just be render a certain radius around the player and just load in and out data as the player moves. The next major system I am prototyping is making interactive tiles destructible and pretty much everything will be destructible besides basic landscape (cars, doors, windows, structures, etc. will be destructible) While I am only rendering a certain amount of tiles around the player, I want to keep the amount of colliders active at one time to be as small as possible for performance and currently the tilemap tool I use automatically merges colliders together. So instead of creating a separate colliders for each of these tiles and having the destructible behavior tied to that object (which my tilemap tool would allow me to do) I was thinking that I would store an array of all the X and Y locations for the interactive tilemap layer and let the tilemap manage the colliders. Then when I hit a collider on the interactive tilemap layer, instead of of getting the behavior for how to deal with the destruction for that tile from that game object, I would pull it from the array I mentioned earlier based on the tile I attempt to interact with which I already have. Does this sound like a good approach? Any other recommendations would be welcomed.
  8. So I am trying to build a turn based rogue-like game and trying to figure out the best way to structure the turn base / action system. I need to be able to support the the same action taking up different amounts of "time" (for example, some enemies should be faster and slower than the player) and different actions should take different amounts of "time" (for example, eating a meal should take long than loading a gun). After thinking about it for just a little, this is my general idea at a very high level. I would have a `ActionManager` class that would store effectively how many "action units" have pasted since the start of the game (probably be stored as a float). Any actor that can perform an action would need to register an event listener on the `ActionManager` to be notified when the "action units" have changed. The `ActionManager` would also expose itself as a singleton allowing any actor that can add to the "action units" to access it that way (right now just the player but I can foresee there being use cases where something else might need to push time forward). The singleton method might not be the best approach for this but it is probably the easiest and want to get something working before worrying about that part too much. All actors that can perform actions would need to store 2 things. One would be the last value of "action units" that it received. The other would be a list of pending actions it wants to perform (to be loaded in some fashion, not sure right now but not critical to the topic at hand). Now any time a method on the `ActionManager` singleton is called that changes the "action units", an event is fired to all listening actors. Those actors would then check the difference from the newest value of "action units" and the last one it stored. With that value it would then loop through the queued up actions is has stored, each which would have a "wait for remaining action units to pass" value. It would take that value and subtract it from the difference. If the result is a positive number, it would just update the "wait for remaining action units to pass" value. If the number is 0, it would perform the action and take it off the queue. If it is a negative number, it would perform the action and take it off the queue and then check the next action until the calculation is 0 or higher. With this system, I could say a player movement cost is .25 "action units" and one enemy might have .33 "action units" cost for movement. Every time the player moves, it would update the `ActionManager` and when the player has moved 4 times (resulting in an action unit of 1), the enemy would have only moved 3 times (1 / .33). This structure for this kinda of system seems like it would be pretty flexible. The biggest concern I have with this system is that I want to make sure it has a little overhead as possible since it will be core to the performance of the game I think. The actions in the queue I hope I can make as dumb as possible where it is really just setting data and ideally I can make the task of filling up the queue be a background process (so that when the player is doing nothing, other actor queues are being filled up to a degree) but that is another topic all together that I am sure I will be making posted about here in the future. Any kinda of critiques, opinions, ideas, suggestions, etc. for the high level system to laid out above would be most welcomed.
  9. Starting A Game Development Video Series

    Part 2: https://youtu.be/3rUDFaZQOVo Part 3: https://youtu.be/0kjzpcXu_Mg Part 4: https://youtu.be/l65Yx4-OXu4
  10. So I am going to be trying something new for me and create a series of videos as I beginning developing an ARPG. I have uploaded the first video that is just a basic intro to the series and general idea of what I am going to be creating: Part 1: https://youtu.be/hUX6jHboKkU Part 2: https://youtu.be/3rUDFaZQOVo Part 3: https://youtu.be/0kjzpcXu_Mg Part 4: https://youtu.be/l65Yx4-OXu4 Part 5: https://youtu.be/Q3dz3MmFWho Part 6: https://youtu.be/U-0j2AChz9Q
  11. @kburkhart84 Yea, having intellisense support would be nice and while my expectation of even releasing this game are somewhat low (since I am really just doing this as I enjoy coding and enjoy gaming and this combines both of those), I would like to not restriction myself from not allowing modding plus I prefer this method for my own development as adding a piece of loot is as simple add an items to the json file and nothing more. I also don't have to worry about the order of the items with dynamically generating my string -> id mapper as with a class the manually sets the ids, if I remove an item in the middle of the list, all the ids afterwards would get messed up. I am sure there are ways to work around that (using an enum might work) but dynamically generating the mapper makes it so I don't have to do anything special for it and I can organize my files any way I want, change the loading order, etc. without much worry.
  12. Thanks for all the feedback, for some direct responses: Yea, I am familiar with over engineering and am definitely guilty of doing that from time to time in my day job but under engineering is something that can also lead to bad things like a system that requires a lot of effort to work it or major / total rewrites. Just trying to find a good balance for my initial implementation so that whichever way I go over (which I am sure I will), it might be an easier refactor later down that road if that needs to happen. I know about how game I have played in the past do handles thing like this however I am know that games like startbound has a string id or string to int id mapping (since you can do things like `/spawnitem wheat` in their in-game console) and pretty sure rim world is also similar based on the modding docs (http://rimworldwiki.com/wiki/Modding_Tutorials/Weapons) where none of the items seem to have an int or hex based id (closes thing that looks unique is `defName` which is a string). --- I did some performance testing with a database of about 9000 base items loaded and when attempting to just use an int id in code to access data 10000 times, it took `0.00005` seconds and when when using a dictionary to get the int id, it takes `0.005` seconds. So while it is certainly a lot slower (by a factor of 100), I think this is an extreme case and I can't see any real reason I would ever need to try to access more then 100 items at a time (which is still an extreme case I think) so I think I am going to go with this pattern for the time being. I am always doing the conversion from string to int as the first thing and then using the int going forward so I am minimizing the amount of string -> int conversions.
  13. I guess my though process behind using a string is that it is recognizable and rememberable, it is easy to know what "WOODEN_AXE" is but not 173.
  14. So I am building a mix of a 2d survival / action rpg (more towards the action rpg) and something that I am going to need to be able to keep track of is loot. I am going to have hundreds of base items I need to keep track of and then also each "entity" that can drop items will have a loot table of what items it can drop that I need to keep track of and I am trying to figure out an efficent way of doing this. I have an initial idea but what to get input on it. NOTE: I am doing this in C# (Unity to be more specific). I want to have 1 main class that would store an array of all possible items that can drop which would probably be read in from some sort of data file. Each of these items would have a unique string identifier so I would want to also store a dictionary<string, int> which would allow to easy access to the item by the identifier like this: Item item = Items[itemDictionary[id]]; I assume this would be more efficent than using a List and doing something like filtering especically if the list of items gets really large. Then each entity would have an array of all the possible items it can drop by storing the string identifiers. Then when the entity needs to drop a piece of loot, I can just pick a random index from that array which will lead me to the item from the main class storing all the items to know which item to drop. Obviously this is a very high level overview of what I am think of implementing and I am sure as I expand thing, stuff might have to change but as a general concept, anyone have any feedback on this?
  15. Thanks for the input all. I have decided to go with using a good portion of procedurally generated content. While I am going to have a number of static maps / map sections, I don't think my game idea is going to have enough functionality the make a fully static world work all that well.
  • Advertisement