How can one add a level to an already published ios android unity3D game on a daily basis? How can one add a level to an already published iOS Android Unity3D game on a daily weekly basis? I know this probably isn't feasible but it won't harm if I just made sure of it. Our game requires to allow access to just one level a day week. You may access levels that were released on previous days and play to your heart's content but all players will get access to a new level every day week. I know this may sound crazy but the concept requires it so just roll with me. Is there anyway to achieve this for iOS Android games built with Unity? Of course, we could package a whole game with 10 levels and allow access to each level after a set time, but the game will need to talk to a back end CMS all the time to allow login and verification of users, make sure they aren't cheating, etc, etc, over proper security and https (proper anti cheat solutions are a must and that's why maybe HTML5 route is better). We are now moving towards doing all this in HTML5 and completely bypass Unity, but was hoping to find a solution with Unity because 3D is better than 2D depending on the situation, and some levels could be 3D while others 2D. Patching updating everyday to upload new levels won't go down well with anyone, the app stores or the users.


Distributed C game server which use database My C turn based game server (which uses database) does not stand against current average amount of clients (players), so I want to expand it to multiple (more then one) amount of computers and databases where all clients still will remain within single game world (servers will must communicate with each other and use multiple databases). Is there some tutorials books common standards which explain how to do it in a best way?


How can I stress test my sever for the game Rust? I am looking to stress test my server for the game Rust and monitor CPU, RAM and FPS. I could not find much around. I general I think I will need a good amount of compute power, bunch of cloud based VM which generate the load through UDP using some headless client. Monitoring CPU and RAM should be fairly easy, but how about the in game FPS? Also I could not find much about Rust clients that could simulate a player.


How should I implement lag compensation in my racing game? I've looked around and I see a lot of discussion about lag compensation for FPS's, but none for racing games. I know Mario Kart uses some sort of interpolation for other racers, but it doesn't provide very smooth results a lot of the times, when the simulated kart goes way off course and then teleports back on track with the next server update. I think games like Forza also use interpolation, but the cars in games like that move a lot more predictably, so it doesn't seem noticeable. If I'm going for a game with the same type of chaotic movement that of Mario Kart, will I just have to accept that there will be sudden visible teleporting when a player has a bad connection to the server?


Do I need to create my own or use a commercial server for the features and matchmaking options I want my game to support? So I'm developing an indie turn based game for iOS and, in coding up a Game Center matchmaking class, I'm starting to question whether Game Center is even the best choice for what I want this game to do. I need to figure out whether I need to create my own server, invest in a preexisting client or server service, or if I even need to use a server at all. If I do need to use a ready made service other than Game Center, which server would accomodate my game's needs best? I have limited resources and funds. Here is the list of features I want my game to support, ideally Turn based gameplay (a la "with Friends" and "with Buddies" games) Smart matchmaking (matching users up with other players of comparable skill achievements) Random matchmaking Facebook matchmaking Specific username matchmaking Contact list matchmaking A way to select what "type" of match you want to challenge an opponent to. (In random, smart, and Facebook matchmaking, there will be different "wagers" the player can make. e.g. "I wanna play a random opponent for 1000 points. Now, I wanna play my Facebook buddy for 1,000,000 points." There will be a predetermined range of amounts you can play for. It won't be customizable.) Buddies list capability (Game buddies, as opposed to contacts and Facebook) A higher concurrent game cap than Game Center offers (which I still can't really find a straight answer on) Scalability (it should support 2 or 20,000,000 players) Objective C compatibility Flexibility (for all the stuff I haven't thought of yet) Am I dreaming, here? Is there even a service that can handle all of these features? Do I need to invest months in learning a networking language to build my own? If so, how much would I need to spend on hardware? I've been looking around all morning and, so far, the only seemingly viable option is SmartFox. Under "Everything and the kitchen sink" section here, it says they support "virtual world with Zones, Rooms and RoomGroups, create complex game challenges, send invitations, manage buddy lists, create custom permission profiles, oversee the security aspects and tons more." http www.smartfoxserver.com overview platform Is there an option that Im just overlooking? Thanks for any help anyone can provide. Sorry for the long poast. One last question Does anyone know which server Dice with Buddies uses? I was experimenting with how many concurrent games I could get going and my ADHD kicked in at about 80 games. 80 concurrent games would be great for my game, but again, I need the other features I mentioned too. Thanks again.


What's the best server architecture for real time games? I'm developing a Real Time game which should hold thousands of players in real time (FPS like. max 1s lag). What would be the best infrastructure for this? My idea was using 2 server clusters one for the Server End (all the computing side) and one for the Database end, where a load balancer is "responsible" for each of the clusters. One main server will receive the requests from the users and send back the IP address of the relevant server that the user can work this. The database cluster will use database replication for consistency between the databases. There should be a geographical load balancer as well so it will assign the regional load balancer to each user for best response. I'm using .NET MSSQL for the game. Thanks!


How should I implement a timer in a strategy game? I'm developing a real strategy game for Android and want to implement timers. Those timers will represent the time remaining until some building is finished. Say that i have a building in construction that takes 45 minutes to be completed. How can I communicate this timer information between my client (Android app) my server and my database? Should I communicate to the server every second in which state my timer is? Should I even do this on the server (i.e., should the timer run on the client)? I'm inclined to assign this task to the server for security and integrity reasons, but i'm not sure on the way i can accomplish that.


how does server communication work in a flash game with a php backend I am trying to create a browser game using actionscript flash. Currently, I'm trying to understand how I would go about creating a back end which interfaced with my MySQL database. As far as I understand, If I create a php file on a webserver called test.php and then navigate to a webpage hosted on the server eg. www.example.com test, the php script will run and display the result in my browser. This would use http. Is this how communication between client and server usually works in a flash game? for example, if the game needed to query the db. Would actionscript have to essentially invoke the url of the php script that would execute the query? it could then parse the data and use it. If this is the case, then is JSON considered a good way to transfer data over http?


Game server position tracking How would you go about determining a players position server side based off player input? The Setup Player sends packet to server containing the command and view angles. Server takes the direction and multiplies it by speed. Say a player is going up a hill. How would the server make the players position reflect that the player is going up a hill. The way i see doing is taking the ground height under the player and calculating if the height change in direction x is too high. However calculating that info for n players say 1000 would be very intense. So what is the proper way of determining a players position based on input with a client server setup with the server being authorative. There is 10 updates per second.


How to achieve game server redundancy? The game I'm developing has a simple game server which stores inventory and hero data for each user, as well as deciding the outcome of some random events. The server interacts with PostgreSQL and responds to HTTP queries. It runs on EC2 and Microsoft Azure, but these hosts sometimes become unreachable for a few minutes, and one week the EC2 server froze every day. What are the strategies to make sure a server is always available? Non solution Multiple servers with their own databases, and the client will try to connect to a different server after a timeout. Of course, their data will be absent if it's a different server. Solution 1 As above, except whenever player data changes, that change is stored, and each player's data is replicated to the other servers (bidirectionally). The disadvantage is that this solution is "home grown" and prone to mistakes. Solution 2 One primary server (let's leave sharding for later), and one or more backup servers, with the database being replicated. When the primary server becomes unreachable, a backup server is made into the primary server. Problems this needs additional technology for directing queries to the right server, and also to decide when a backup server needs to be promoted to primary. Can this "manager" also hang? It sure can if it's on AWS! That would bring the whole system down. Solution 3 We could pay for database hosting with some guarantee of reliability, and have multiple servers but just one database. We would assume the database is reliable (but still back it up). The user could connect to any reachable server, and the servers would not need to worry about having stale data, since there will be only one database. (Again, sharding is a separate problem, and we could just multiply the whole setup without fundamentally changing its architecture.) So how is reliability achieved when individual servers aren't reliable? I like solution 3 for its simplicity, if a 3rd party database can be relied upon.


How to design game server to mitigate DDOS attacks I'm in the design phase of a turn based game with low load on the server ( lt 1 message every 10 seconds per user, lt 50'000 users at a time). The game is multi platform. The protocol has not been decided yet. How can I mitigate DDoS attacks against such a server by design?


What are useful server metrics to gather for a table card game? When building a game server intended to accomodate large numbers of simultanous games (e.g. table card games), where the server manages lots of tables and each table has up to a small handful of users, what metrics are most useful to collect and why?


what is the best way to code an online multiplayer game? so i want to create a simple game that runs over a network but I am having trouble deciding what needs to be done in terms of what the server needs to do and what the clients need to do. I understand I should use UDP sockets but I am unsure how to implement it within a game and have all the clients be in sync. Should the server side have like a master copy of the game where i basically runs the game and accepts moves, plays them in itself, and then sends the current state of the object to the other clients?


Do I need a backend engineer for my studio right now? I am working on a mobile game that requires a well thought out backend, because it spans across the healthcare data science space and we need to be compliant in terms of security regulations in how we approach this. Think something like Fitbit. My team is nearly finished with the client side game aspect but I am wondering whether I need to take on a short term contract part time backend engineer to create our entire backend infrastructure OR someone who would work on this full time with our team. Here is what we would need to do Setup our entire backend infrastructure and plug this into Unity This would require knowing how to handle (transmit receive) data securely, and also perform computation with that data in the cloud Set up an API where other developers can query our data Set up our dev ops infrastructure (Docker, Jenkins) for the future The kicker here is that we are not yet live and are just in a testing phase. I don't want this to be 2 3 weeks of work, with no users for 3 more months while we're working on other aspects of the project, with the dude having nothing to do. Does this sound like a lot of work? Or could it easily take up a devs time for a month or two? Would a short contract be advisable here, or would it be better to hire someone FT and have them grow with us.


Where should I place input output console for server? I'm developing a simple 2d online game and now I'm designing my server. The server will be run on linux vps and I need a way to communicate with it (for example to close it, and as it will be run on vps, simply closing terminal won't work). So I think there are 2 options 1) Write 2 apllications server which doesn't say anything and doesn't accept console input and the second application is console which sends commands to server (like exit, get online players etc). 2) Have 2 threads on the server appplication one is the real server, the second thread will be used for cin and cout. However I'm not sure if this will work on vps... Or maybe there is better aproach? What is the usual way of doing this?


How should I configure firewall for online game server? I'm complete newbie on game server work. As I know, online (massively multiplay) game server should keep some TCP or UDP connection from the user. As I ( newbie) guess, maybe huge count of socket port should be opened. So how should I configure firewall for game server? Or should I use some other special method to security? Any advise will be appreciated.


How should I store game data in a game server? I'm new to game server development. I'm facing this issue I want to develop a card game server, but I'm not sure about the solution to hold the game data while playing. Example In a poker game, when a player makes a move, the server will process the request and send it to all other players. But how will the game server know what the current state of the game is to do subsequent actions? Should I save all moves into database and server will look into it to know the current state?


Keeping Players in Groups tl dr How can one enforce that groups of players stay together in units in Minecraft? I'm developing a plugin for a Minecraft server. It's based off feudalistic societies, like Ancient Europe or Japan. I understand that many ancient societies had advanced battle tactics (like this and this, for example). I think this is very interesting, and would add some more interest to a server. However, Minecraft isn't particularly well suited for this kind of play. Generally, in battles, all the players just run willy nilly and charge the enemy. There are no units of players, much less the units combining in a smart way to defeat the enemy. How can one enforce players staying together in one unit or group? Keeping each player in a certain position no matter what is not an option, since the players cannot PvP. Once players are grouped into units, I assume they will take up certain battle strategies and use them in a smart way.


Spreading server load for a multiplayer game My online game is more of a "highly interactive website", as it is played in browser using webpages and AJAX to communicate with the server, which uses PHP to generate output. The server is fairly standard, using PHP7, MariaDB, and Memcached (to avoid constantly reloading data from the DB, cache hit rate is about 95 ). All of this works. Fairly well, at that, and it can comfortably handle about 1,000 users actively hammering at the core gameplay element. The problem is that it's not scalable. The only scaling strategy we've had so far is "throw stronger hardware at it", which again works but it's not sustainable. I want to look into options for spreading the load over multiple servers, but it's daunting. Most of the game involves manipulating your own characters, and then visiting other player profiles to "interact" with their characters (which awards EXP and bonuses to both parties). There is also trading between players. Of course if this were just a regular website then I could probably just replicate everything and stick a load balancer in front of it, but I'm not sure that'll really work here. I think the most sensible option would be some system of assigning users to a specific server. When you log in a cookie is set to indicate which server you're on, which the load balancer can use to direct your actions to the server your data is on. When visiting another player's profile, the server will request that data from the other player's server. Things like trading will also be handled by having "player one" send a request to their server, which will communicate with "player two"'s server to move data around and complete the action. Is this realistic? Or am I overthinking it? Are there other options? Ideas?


Synchronize turn based browser game I'm writing a browser game in php and Sql. I'm also using Javascript Ajax and Mysql. I'm stack on the battle system because I want to Synchronize the turns of the players in the battle. What I doing is to put two players on a battle. So from the first turn a countDown of 60sec will start. What I am thinking is to use a server function to check the countdown, not to the client side. This because I think that in that case a bad synchronization will came, instead if it is the server to count down. But.. how can I let the server do all this stuff?


How do I write a game server with single threaded networking? I want to write a game server with one thread for clients message handling and use something like epoll to accept network messages. All I O and database access will be processed in a thread pool and they are asynchronous and non blocking. Given such a scheme, how should I handle other events messages (physics, game logic, etc)? Can I implement methods to handle these messages as a blocking interface in the main thread? What simple, popular servers exist (using Cocos d Unity as client) that I could look at for an example of this?


Physics motor on servers, How a billiard server works? i'm trying to figure how a phisics game like billiard works in server side . I'm asking this cause i know how to achieve this in a client , but if i use a phisics motor i think it could be very heavy for a server when i want to have many people in the server. When i see this type of games, it use to be really fast , thinking that server is controlling the movements of course . Cause any other way maybe from client you could have been doing cheats. Then my questions are The server sends in this case, all ball movements? Are the server trusting in clients? In this case How to be sure a phisics motor doesn't have little error. (float decimals differences) And globaly How this type of server works?


save player achievements in local device As an indie developer with zero dollar budget for servers and backend i wonder if there are ways to store the player achievements on his mobile device ?


nodejs game server timer I'm new to game server develop. I'm developing a card game server. How could I make nodejs server wait for few seconds then push data to client after an event fired ? Example in poker game, one player have about 20 seconds to make a move, after 20 seconds server will auto fold and then push a message to another player. How could I make server wait for 20 seconds and then do next action ?


As an Independent Developer should I host my own official game servers My small team is approaching initial closed alpha for testing, however that has brought up the question of whether it is a good idea to host our official game instances from my home office or not. I've run a few dedicated servers before on my home PC (have 3 active as a service at the moment actually) so I'm not unfamiliar with the process. However I'm looking into building a server PC specifically to fulfill that singular purpose. I have google fiber 1000mbps so I don't think I'll have bandwidth issues. But I wonder if any of you have advice and insight into what I should expect, dangers to avoid, etc. Here's what I anticipate, am I missing anything? Masking home IP via dynamic DNS service (pointing to a website to login rather than an IP) Running multiple VMs on a single server to easily manage server resources Initially testing with a few selected users Eventually open up to more users once proven stable


About online game servers and how to handle data So my question isn't about what technology to use or how to do this or that, but a more general question. I'm currently developing a action third person shooter. With elements of RPG weapon,armor upgrades and items. Players will be able to create new games or join old ones. So my question is how to create the game server that players will play in. I have two ideas on my mind. The player who made the game is the server. All data passes trough him and he send this data to the server updating the database of the players with their XP points kills deaths score and other. Or my host machine is the server, the player who made the game just will open new instance on my host and will be like client. And all players send their input data to the host, the host updates the game and send response back to client for any new changes like where is the enemy and other. And if i choose option 1 is there a chance the host to change the game content and manipulate the game results? (I think there is but i'm not sure) And if i choose option 2 isn't that raising the response time and potentially the game lag? or maybe there is another option?


Existing master server software? Considering there are many games out there that use some sort of a server that contains a list of current games servers, is there an existing library I can use instead of writing my own master server? I only wish to store game server data (server name ip, num players, game specific data...). Thanks!


Distributed C game server which use database My C turn based game server (which uses database) does not stand against current average amount of clients (players), so I want to expand it to multiple (more then one) amount of computers and databases where all clients still will remain within single game world (servers will must communicate with each other and use multiple databases). Is there some tutorials books common standards which explain how to do it in a best way?


Calculate resources real time. Sockets or not? I'm currenly developing a game in Javascript. It's a Single Page Application so every change should be pulled from the server without page refresh. I'm currently wondering how I should handle the 'resources in stock' (like wood, food and gold). I know there are more questions like this around here (regarding websockets and Ajax requests) but I'm currently looking for the best solution in my specific case. Scenario Resources are produced every second. So for example, every minute 100 resources are produced. This should be updated live. I know, in this case it's not necessary to really update them live. I mean, I can simply calculate how much resources are produced in the current time minus the last updated time. So no problem here, but there are a lot of different factors regarding the production of resources If a player is attacked, the enemy could have robbed some of his resources. So after an attack, the resources should be updated too. If a player is attacked, and one of his 'productionbuildings' are damaged, he, for example, doesn't produce 1000 resources a hour, but 800 resources instead. So after a building has been demolished, the application should know the new building level to calculate the right amount of new resources. Possibilities So, how should I update the resources for the user? These are the options I think could possibly work Ping a script on the server, which calculates and updates the resources, every 5 seconds. Set up a websocket stream and trigger it after each activity (after an attack, demolished building, ...) Are there any other options? What would be the best way?


what is the best way to code an online multiplayer game? so i want to create a simple game that runs over a network but I am having trouble deciding what needs to be done in terms of what the server needs to do and what the clients need to do. I understand I should use UDP sockets but I am unsure how to implement it within a game and have all the clients be in sync. Should the server side have like a master copy of the game where i basically runs the game and accepts moves, plays them in itself, and then sends the current state of the object to the other clients?


How do I resolve asynchronous client actions against an authoritative server state? I have a multiplayer card game which I am in the process of developing. The game is relatively simple players have a certain number of cards which they can activate, sell, or use in various other ways. The game isn't turn based. Instead, it is asynchronous so that players (A, B, C, and D) all make their choices at the same time. Certain actions will affect the game state. For example, removing a card from the game or adding a card to the game. Players should always be in sync with each other so that, for instance, Player A cannot use a card that Player B has just removed, as it is no longer present. Obviously there are situations in which Player A may remove a card at nearly the same time that Player B tries to interact with the same card. How would the server handle this sort of situation? My original thought is that each client could hash their game state and send it with their command to the server, for example Player A MYHASH Command Pick Up Card Z Player B MYHASH Command Remove Card Z The server would then action the first command and regenerate the hash. Upon trying to execute the second command it would notice the hash sent by Player B differs from the current hash, so the server would reject the request. In the above example Player A would notice nothing and the game would continue normally, but Player B would have to be informed that their action failed.


Choosing a server for a PVP game So I am starting a game with a friend as a small project, and we are considering what game servers would we need. Firstly, the game is a multiplayer(player vs player) game, for example, like an online chess game. However it is real time, so the latency cannot be too high. The players basically take turns, but in a real time fashion. The platform is going to be Android (and perhaps extend to iOS in the future) The server would need to synchronize the players' moves to each other devices. I don't really need anything large scale and I am thinking of using PHP since the volume of data isn't really that big, this is like a web based game with a requirement of a slightly lower latency. What would be the advantages and disadvantage of using Apache PHP for a game like this? If that seems to be a bad choice, I would be grateful if you can share your experience with me. Thank you. (We are both programmers and we are familiar with Java C Obj C Apache PHP Tomcat JSP Javascript)


Is it possible to rent a server for my own game? I'm an independent game developer and I don't yet have a lot of money to buy myself a very cool high speed and low latency internet connection along with a powerful server machine to place somewhere in the world to host my very own game's server application for my fans to play on. I know it's possible to rent a server for an existing popular game (for example, Team Fortress 2), but how about renting a server for my own game that I'm developing? Are there services specifically for that, or should I just rent some general purpose something and go from there? Such a server should be Easy to update With a low latency for a specific region (I'm planning on renting EU and US servers)


What's the proper practice to organize relationship between components in an ECS pattern? I'm new to ECS concept and trying to refactor my app with an ECS manner. After reading some articles, I still don't get a sense about how to organize hierarchy for such pattern. My questions are Is a component allowed to have another component inside? For example I saw a RenderComponent that contains a Mesh inside. Is the mesh also a component or the raw data of it, which should be stored inside the RenderComponent? What happens when an instance of component needs to be shared by two entities? If an entity should be just an integer, how do you organize the relationship between entities? Should it have a parent child linked entity or should all these relationship be managed by the system? Thanks!


ECS System calling other systems I'm trying to build my first (2D) game with ECS but I always end up with some system calling other systems. Here's an example. There is a RegionSystem that manages RegionComponents. On each frame, this system loops through all the RegionComponents and checks if the player is inside any of them. When the player enters the water, the player's sprite must be changed from PLAYER RUNNING to PLAYER SIWMMING. When the player steps onto a teleporter, an animation will play around the player, he'll be rotating and a new level will be loaded. When the player steps into a hole, he will lose some health and will be repositioned in the level. So, first of all, it needs the coordinates of the player's body to check if it is in a region (check point in rectangle). Hence it will ask the RigidbodySystem to get the coordinates. Then if the player is inside a region, it will call PlayerSystem OnInsideRegion(regionInfo). In turn this function, PlayerSystem OnInsideRegion must react differently depending on the type of the region for the water case, it needs to call the SpriteSystem to change a sprite, the PlayerSystem to set a boolean (m inWater True ) and the RigidBodySystem to get the coordinates of the player's body for the teleporter case, it needs to call the LevelSystem and tell him to switch to another level on the next frame for the hole case, well, simply descrease the member m health of the player component, so no need to call another system here. I have the feeling this is a horrible design and does not fit the ECS architecture. I read that people use a message system where systems can subscribe and unsubscribe to particular type of message. But I also read that it can be tricky to react to them in a proper order.


Entity component system where did attributes and behaviors come from? I recently spent quite some time understanding and building a component based system. I got stuck on a few problems and after searching for quite some time ran across this answer which is talking about behaviours and attributes. From what I understand, attributes are an entity's data I thought that's what the component is? And what are behaviours? Is it another term for Entity Processing System?


Handling of persistent key presses in an ECS I'm currently in the planning phase of a game. The whole thing should be based on the entity component system (ECS) pattern. All logic is concentrated inside of the systems, i.e. that the components hold data only. Communication across the systems is performed using asynchronous events. Using this design, I'm unable to find a clean solution for the simple example task of moving player While the input system generates key press events, I'm looking for a way to query the key state, since the player will most likely want to move the player for more than one frame. There are two possible ways I can think of solving this problem Retrigger the key press event every frame Pass the corresponding systems a reference to the input system Neither possibility sounds "correct", since they both require the abuse of the design. Is there a better approach for solving this issue?


Packet Event Based Entity Component System I know what one of the big commonalities I see in ECS projects is that there is a main game loop that iterates through systems and calls their respective update methods (for example, RenderSystem). I'm a bit stumped on how this applies to an event based game where the client sends packets of information and you update from there. For example MovementPacket Read incoming movement packet and send to appropriate packet handler, which makes changes to appropriate components regarding entity through systems. Packets are then sent back through the systems (which work with components to access the data needed to write these packets). nbsp Now, I'm not sure where a game loop really comes in here, since everything seems to be event based. I'm scared that most of the work I'm doing ultimately for ECS just isn't being done right. My systems are typically becoming "containers that do logic and stuff, but don't operate within a game loop." In fact, the game itself doesn't have a game loop, since we haven't really found an area to insert it in. Is the approach just wrong? Is my approach towards interweaving ECS with this packet based game for the most part incorrect?


ECS, databases, XML and serialization My entity component system engine is coming along quite nicely I have two very different apps working on the same executable. (One 2 d scroller, one 3D Asteroids type game). In the interest of getting something working, I've been creating XML definitions of the games, and editing them using a small custom tool that does little more than ensure that I don't add components that don't exist, and that the files are valid XML. I'm at something of an apex or flection point in that the tools and process I'm using really aren't suitable for production. Hand editing large XML files is an error prone, painful process. (JSON is well supported and pithy, but still requires visual syntax checking.) I could switch to a database such as SQLite, but I have yet to find a good graphical interface (something along the lines of SQL Server Management Studio would be nice). Are there any COTS tools that can ease this process? I found a C SQLite implementation with a basic ORM, but it doesn't support complex types like Vector3 or Rectangle. I can serialize these into strings or edit the ORM code to support those types, but then I wind up with my own branch of an OSS component which invites maintenance headaches further down the road. Another thought was to just do everything in SQL Server and generate the XML from there, and have a tool that keeps the DB schema in sync with the component types in my engine, which is similar to using an ORM. What's a good solution for this problem? I've read that bigger studios (as in, more than one guy) build their own tools for this kind of thing. I can do that, but I'd really rather be writing my game than building a tool set that only I will ever see. To clarify how do those that use entity component system engines create and maintain their data that defines the game?


Entity Component System Physics Animation Matrix Calculation? The problem is how many times the matrices representing the bones (for animation and rendering) of an entity get calculated. If i have these components Position Skeleton (holds matrices for bones) Physics Animation When the physics get's updated, the position is changed to move the entity. This sends a message, that position has changed. The skeleton takes note and updates the matrices for the changed position (and potentially rotation). The animations are then updated in a separate system, the skeleton then gets updated and changed again. So essentially the matrices are being updated twice (unnecessarily) instead of just once. Am i going about this the wrong way? Is this just the price of having everything disjoint?


Central logic in entity component architectures I've build a architecture based on the entity component system idea. So I got Components Just store Data Systems Operates isolated on Components Scripts Which are just objects from type Script and attached to a ScriptComponent. A ScriptSystem will execute the init() and update() functions on the scripts then. However, I'm wondering where to place the central game logic since the I have to check a few things about the overall game process, holding the map, counting the points, checks the points if they are enough for the end screen, etc. ... Should I create a single entitiy with just such a script attached to it or are there better solutions out there?


Why are entities in a component system composed at run time? Why are entity component systems the way they are? For example as far as I have seen it may look like this class Entity list of components add component remove component update comentent .... So you are building your entities at runtime. I assume it will look like this Entity ork ork.add(AI).add(movement).add(physics).add(renderer) The problem I see with this approach is that errors appear at run time instead of compile time. It also seems to add a lot of potential errors for example the AI system only makes sense if the entity also has a movement component. What is the advantage of building your objects that way instead of doing it like this? class Ork IEntity movementComp AiComp physicsComp rendererComp .... wire everything together One possible advantage that I can see is that object creation takes less code because you don't really need to wire up your objects, you just add your components and your done. Would you please enlighten me?


Should I load scenes from files, or hard code them? In a game engine I'm working on, I'm using scenes similar to what you would find in Unity. The entities, in my game, are composed of reusable components and custom data which is linked to those components. Entities have children, and one parent. This is shown, below class Entity ...custom data here... let parent Component var children Component var components Component ...methods... If the entities did not have custom data, then creating a scene would be described by the following steps Loading a file into memory. Creating a tree of entities. Adding components to them, with parameters listed in the file. However, this does not leave room for custom data. My other alternative is to create a scene by creating a scene object, then hard coding the entities in. It would look something a bit like this var opening scene Scene() opening scene.addEntity(Player()) opening scene.addEntity(Car()) opening scene.addEntity(Terrain()) ... The downside to this is that everything is hard coded. What can I do to create scenes in a game more efficiently?


How to use batch rendering with an entity component system? I have an entity component system and a 2D rendering engine. Because I have a lot of repeating sprites (the entities are non animated, the background is tile based) I would really like to use batch rendering to reduce calls to the drawing routine. What would be the best way to integrate this with an engtity system? I thought about creating and populating the sprite batche every frame update, but that will probably be very slow. A better way would be to add a reference to an entity's quad to the sprite batch at initialization, but that would mean that the entity factory has to be aware of the Rendering System or that the sprite batch has to be a component of some Cache entity. One case violates encapsulation pretty heavily, while the other forces a non game object entity in the entity system, which I am not sure I like a lot. As for engine, I am using Love2D (Love2D website) and FEZ ( FEZ website) as entity system(so everything is in Lua). I am more interested in a generic pattern of how to properly implement that rather than a language library specific solution. Thanks in advance!


Why is it a bad idea to store methods in Entities and Components? (Along with some other Entity System questions.) This is a followup to this question, which I answered, but this one tackles with a much more specific subject. This answer helped me understand Entity Systems even better than the article. I've read the (yes, the) article about Entity Systems, and it told me the following Entities are just an id and an array of components (the articles says that storing entities in components isn't a good way of doing things, but doesn't provide an alternative). Components are pieces of data, that indicate what can be done with a certain entity. Systems are the "methods", they perform manipulation of data on entities. This seems really practical in many situations, but the part about components being just data classes is bothering me. For example, how could I implement my Vector2D class (Position) in an Entity System? The Vector2D class holds data x and y coordinates, but it also has methods, which are crucial to its usefulness and distinguish the class from just a two element array. Example methods are add(), rotate(point, r, angle), substract(), normalize(), and all other standard, useful, and absolutely needed methods that positions (which are instances of the Vector2D class) should have. If the component was just a data holder, it wouldn't be able to have these methods! One solution that could probably pop up would be to implement them inside systems, but that seems very counter intuitive. These methods are things that I want to perform now, have them be complete and ready to use. I don't want to wait for the MovementSystem to read some expensive set of messages that instruct it to perform a calculation on the position of an entity! And, the article very clearly states that only systems should have any functionality, and the only explanation for that, which I could find, was "to avoid OOP". First of all, I don't understand why should I refrain from using methods in entities and components. The memory overhead is practically the same, and when coupled with systems these should be very easy to implement and combine in interesting ways. The systems, for example, could only provide basic logic to entities components, which know the implementation themselves. If you ask me this is basically taking the goodies from both ES and OOP, something that can't be done according to the author of the article, but to me seems like a good practice. Think about it this way there are many different types of drawable objects in a game. Plain old images, animations (update(), getCurrentFrame(), etc), combinations of these primitive types, and all of them could simply provide a draw() method to the render system, which then doesn't need to care about how the sprite of an entity is implemented, only about the interface (draw) and the position. And then, I would only need an animation system which would call animation specific methods that have nothing to do with the rendering. And just one other thing... Is there really an alternative to arrays when it comes to storing components? I see no other place for components to be stored other than arrays inside an Entity class... Maybe, this is a better approach store components as simple properties of entities. For example, a position component would be glued to entity.position. The only other way would be to have some kind of a strange lookup table inside systems, that references different entities. But that seems very inefficient and more complicated to develop than simply storing components in the entity.


Superclassing RPG Game Entities I am in the design process of an RPG game and I have no experience at all in game dev. This question is about how I should approach entity management using OOP classes. My train of thought is as followed Have Entity interface with basic update() function "Mortal" class and "NPC" class implement Entity "Hero" and "Monster" class inherit from "Mortal" class In this case, Mortal class are all those entities that have statuses such as HP and MP. NPC are self explanatory. I am sure my approach is naive so I would like to know the pros and cons and what would be a better way to approach this.


Entity Component Systems with Model View Controller Can the Model View Controller design pattern be used with non OOP coding style, specifically with Entity Component System?


Ways to persist entities and components in an ECS? I am working on a small multiplayer game with rpg elements using java and quot Artemis ODB quot . Most of the logic is already done but one important thing is missing. The persistence. So i am searching for different ways to persist my game. One thing is important, the world is huge and i cant load in the whole world at once. I already stumbled upon two different ways on my own. Using a relational database or a nosql database. But one thing scares me... entity references. In my game i have an player entity and item entities. The player entity owns a inventory component which stores a reference to some item entities. In my ecs, each entity reference is an simple integer. So this looks like this... Represents the Inventory of our game, contains references to entities acting as items. public class Inventory extends HibernateComponent public Set lt Integer gt itemEntities new LinkedHashSet lt gt () Why does this scare me ? Well... Entity references are Integers in my case. They are no real ID and i cant set or change this quot ID quot of an entity because my framework permits it. This brings us straight to the problem. When i serialize this component or the whole player entity it would look like this. Inventory itemEntities 40,2,5,50 So when we save this and load it later on we have no entity with the id 40... and even if we recreate that entity we cant set it to an id of 40, because the frameworks permits it. So how the heck do we save references between entities ? So all in all... what are common ways to save, load entities from an ecs ? How do you do it ? And what would you recommend ?


in an ECS framework why are components indexed via their name rather than an Enum? I have been reading through a number of discussions on ECS framework and very often I see components being referred to via name rather than through a string object such as an enum or a struct. I'm starting to build a test implementation myself and feel as though they should have a strong type rather than a string so that I can pick the component I am looking for from a list rather than 'guessing' with a string. As an example you will often see Entity.GetComponent("Position") rather than Entity.GetComponent(ComponentTypes.Position)


Defining collision response in an Entity system I'm building a really simple top down 2d shooter which uses an Entity Component pattern. I've added several different entities to a level and given them different collision groups. I have an entity to represent a teleporter (assigned to collision group A), a player entity (group B), and a bunch of enemies (Group C). I understand that the actual collision response should be decided in the collision System based on the groups that the colliding entities belong to. What I can't figure out is how to define the specifics of a collision. For example, if a player collides with a teleporter I need to move the player across the level. Where do I store the target location? I'd assume in a component on the teleporter. Should I create a whole new component just for that data? I feel it should be stored in the teleporters collision component but no all entities that use the collision component will require this data. Could someone please try to enlighten me? Thanks


Should components in Entity Component System pattern have logic? Is often read that in entity component system pattern we should treat components just as a passive data structure with no logic at all, this way we follow to a data oriented design approach with efficient usage of cache memory and gain performance. I was developing a simple game using this rule and when the game was getting bigger I start facing some serious code smells such as repeated code in systems, let's suppose its a shooter to illustrate an example. In this shooter I had bullets being fired so I created a BulletComponent and a BulletSystem that handles when it collides and make some damage and if don't collide with anything the bullet dissapear in five seconds. Then I wanted some explosives so I created the ExplosiveComponent and ExplosionSystem, once the explosive is placed it explodes in ten seconds. At this point we can notice the first repeated code between systems then we can make an abstraction and we create a DurationComponent and a DurationSystem so the bullet and the explosive contains it with the time it should last.Then I realized that when the explosive should explode I want to create some particle effect in the area so this abstraction is no longer valid as I want to perform differents actions when time runs out, but if I do as at the beginning I have the repeated code between systems (ugh!). This example is simple but I'm facing this with more complex things like AI, or reacting to collisions. One solution I came to this is that I really wanted an ActionComponent with a ActionSystem that executes the action contained in the component but this way I'm breaking that components only contains data and they should not have logic! this is more an 'hybrid' approach. But if you start thinking deeply the ActionSystem is very generic and you can almost do anything with it so it's hard to determine whether a system is necessary or not. The same can be applied to collisions, instead of having lots of systems with logic for different entities colliding, you can just have a CollisionHandlerComponent with the logic on it for each entity. I found the following advantages making generic systems like this Higher flexibility (you can customize each entity easily) No repeated code Less systems (more performance?) But as I said the main disadvantage is that is really confusing if a system is needed as you can stick logic to components. Is it wrong to follow this sort of hybrid ecs? If yes, what would be your approach to the example without repeating code in systems?


How should one component "trigger" another one in a component system? In my game I have a MoveComponent and a ClimbComponent. Some characters can only move around on one level, others are able to climb to the next floor. My intention is to have characters randomly be able to climb if the are about to bounce into a wall. How would I manage this? Should the ClimbComponent be added dynamically and also be removed again, or should random characters always have the ClimbComponent and it would be activated and deactivated dynamically?


Where should complex state logic in an ECS reside? I've been using ECS for a while, at the moment I'm using my own, but it's pretty standard. Components are data only, Entities pretty much just a Map with some additional metadata and Systems that match combinations of components and contain the logic. You have combinations of components that result in the more general functionality. For example Position Graphics gives me some nice static background image. Position Graphics Physics gives me a entity that can move around etc etc This question is about the various options for implementing more specific game logic. But say I want to implement a Door. It has Position, Graphics and a Collidable Hull but it needs 2 states, open and closed. When its open it has texture A and its Collidable Hull is disabled, and when its closed it has texture B and its Collidable Hull is enabled. Lets say the state change should be triggered across some internal channel in the engine. What are the options for implementing this state change? Option 1 is to create Door component, with say 2 variables, door state and state change channel. I'd also need a door system that handled the logic to manipulate the components when it receive the open close message. Option 2 would be to create a FSM. The FSM is probably also a component with a corresponding FSM System. Logic and state would need to reside somewhere, possibly by sub classing the FSM or having a generic property map in the FSM and static logic functions for the Door defined elsewhere. There are more exotic alternatives to FSM's i.e. Actions Lists or Behaviour trees, but they are similar to option 2. What considerations are there for choosing a full component system over an more generic FSM type solution? What if I had 100 different game objects with different behaviours? Would you really expect 100 component system pairs for each one or would you try and create a more generalized solution? Are there any other options?


How can I utilize external libraries within an entity system? I'm implementing an entity system for educational purposes. I wanted to focus on the system itself and don't know much about rendering and physics, so I'm using external libraries for those tasks. These libraries come with pre defined classes for their objects (sprites, bodies, etc.) These do not fit into my entity system easily. How can I utilize existing libraries and classes within an entity system?


How do components and systems relate to each other in an entity component system? I'm trying to learn and understand the ECS (Entity Component System) so that I can create a game using this design pattern but I've got a lot of things that I still don't understand. Lets say I've got a PositionComponent and a MovementSystem or PhysicsSystem. The PhysicsSystem will heavily rely on the PositionComponent since in order to calculate, for example a rigid body motion, it needs the x and y positions (in a 2D game) wich is contained by the PositionComponent. What is the relationship between Components and Systems? How does the MovementSystem get the x and y values from the PositionComponent?


Handling movement using an Entity Component based System Architecture I have seen various descriptions of how to handle movement in a component based entity framework. The most common I've stumbled across is the idea of using components called Controller, Physics, Transform, Velocity, and Collider. The idea here is that the Controller influences the Velocity component when movement keystrokes are detected. The Velocity component in turn influences Physics. Once the simulation has been stepped, the Collider is either affected if a collision occured or is not if no collision happened. In the end, the Transform is updated with the new position from the physics simulation step and thusly the Renderable needs to be adjusted so it is drawn in the proper location. I have often read that one needs to consider both physics driven and non physics driven entities. As outlined in the above paragraph, manipulating physics driven entities seems like a piece of cake. The difference with non physics driven entities is that the Velocity component values need to simply be applied to the the Transform based on delta time. This would allow moving the entity without being concerned with physics nor collision detection. For physics driven entities, one simply iterates entities with both Velocity and Physics components. But for non physics driven entities, simply iterating over entities with a Velocity component isn't sufficient as it would include the above subset as well. So there must be some factor that clearly separates these two cases. So with these two cases in mind, how would movement actions that influence the values of Velocity be carried out in such a system to manipulate both types of entities whether physics plays a roll in their movement or not?? And lastly, considering that there may be times where the transform for an entity needs to be manipulated directly, such as player clicking on a portal to be teleported to another x y z position, how would one properly propagate this change to adjust both the physics step simultation and the renderable's draw location? EDIT bobenko Your explanations provide insight to the most common case where objects are simulated via physics but I'm somewhat lost on the Kinematic aspect regarding updating an entities position via a velocity value? Are you simply implying that some code of my own will apply movement to the entity via velocity, thus being Kinematic? I still am interested in your explanation on how to avoid cyclic notifications effectively when aspects of these components involved change. For all who answered, I'm still not clear how would you handle teleporting an entity from one position to another? Would this involve turning off physics, teleporting the player, then turning physics on after teleport finished? Turning physics on off can be as simply as setting the entity as Kinematic YES NO, right?


Should I implement Entity Component System in all my projects? I'm not here to ask for any specific code implementation, I'm here just to make my ideas clearer. But let me explain the situation I have already developed some little and amatorial game projects (never published tho) but I recently found some interesting articles about ECS and I began to read more about it. I found the whole ECS concept every interesting and I thought I could implement it in a very tiny game I'm working on in my free time. The problem is should I implement this pattern on a every little project with simple game mechanics and poor gameplay ? The 2D game I'm working on will be entirely developed by me, so I do not actually need to make the code easier to mantain by other people. This game will basically have just 2 players, some weapons and a large variety of bullets and superpowers. No IA enemies, no vehicles, static and tiny maps and.. Just that. It will have, of course, a simply physics system (just to make players fall and bullets move, for example), and a tiled but very little map which is editabile by players (destroying tiles). So the point is why should I actually write an ECS for such a basic game ? Do I really have any real advantage considering the game design ? I mean, I know it is very good to make your code very flexible and easy to mantain even in the future, but I also know that this pattern was invented to avoid some limitations and the code duplication which the old hierarchical game structure provides, but this game doesn't have a wide hierarchical structure, as far as I can see. I started coding it, but I discovered some aspects which, to be honest, scare me. Like having all the components talking to each other through a reference of their owner (the entity they are bound to), which as far as I know, is not very good to avoid cache misses. The last thing is that I have the feeling that I won't write more than 2 components of the same type, and this would make the ECS less useful. I know I don't have the whole ECS concept really clear in my mind, this is the first time I implement it, by the way, but I hope you got the point of my problem.


Particles instancing groups in an Entity Component system I've been playing with an entity component system design recently, and I've come across a couple of stumbling blocks. Instancing Let's say I have a few hundred "things" (asteroids, chickens, whatever) that are being drawn with instancing. In a classic component hierarchy, I'd have a game object that keeps the individual instance index and vertex buffers, as well as the second dynamic vertex buffer for the instance data (collection of matrices, etc.). That object would be responsible for checking collisions with other objects and between the instances themselves. In an ES system, I'd like to track each instance as an individual entity, but I don't want to give up simplicity and performance of instancing. The first thing that occurred to me was to create an "instance group" component, with a field that defines a group ID to enable handling of multiple types of instanced geometry. An "Instance System" would collect those components and maintain the instance vertex buffer. My entity manager already notifies systems when an entity is created or destroyed which makes this part pretty easy to implement. My confusion comes from how to cleanly integrate that with the rendering system. If each instance appears as a separate entity with a "renderable" component attribute, the render system will process them individually. I could Include a special case for entities that have both a "renderable" and an "instanced" component, but that seems messy and feels like starting down the path of having a huge render system with tons of special cases. Have the render system maintain a collection of instance vertex buffers, query the entity list for "instanced" entities, filter based on a group ID, etc., and render as appropriate, so the render system becomes responsible for maintaining instance collections, but that seems like the wrong place to put that sort of logic. I could also include a single entity in addition to the instances with, say, an "InstanceOutput" component attribute and a Renderable component, and remove the Renderable component from the individual instance entities, giving a single render point for all of the instances. This component would probably also server as a place to keep the geometry and persistent instance vertex buffer. Is there a better way? Rendering I have several types of renderable entities. Some have procedural geometry and textures, some are just sprites, some are text displays. What's the best way to differentiate these from the point of view of the rendering system without having to write a massive switch statement? In a game object hierarchy, each of these types would have their own Draw() method, but moving the logic into a Render System doesn't seem to provide a lot of flexibility in terms of different effect parameters, etc.


Component Entity Systems Code Generation I'm really enjoying component entity approach (I'm currently using ASH haxe, but particular language framework doesn't really matter). However the problem is there're way too many elementary classes that need frequent update. So I'd like to have something like yml config file for components and nodes, and actual classes to be generated from it. Is there any already existing solution that utilizes such codegen, or maybe some generic codegen solution that should be easy to configure for such task?


Whats the most efficient method for controlling entities? I'm creating a tower defense game and I'm having logistical issues trying to figure out how to best have all of the enitites do their apporiate task. I have considered just constantly looping through a list of all the game entities calling a onAction() method, but I'm not sure if that is effective. I have also considered having each entity be a thread, but when I am dealing with hundreds of entities, some of which don't need thread time, I'm back to square one. Can I get any suggestions on a solid approach? Am I on the correct track with my first idea? Thanks for any help Aedon


Handling of persistent key presses in an ECS I'm currently in the planning phase of a game. The whole thing should be based on the entity component system (ECS) pattern. All logic is concentrated inside of the systems, i.e. that the components hold data only. Communication across the systems is performed using asynchronous events. Using this design, I'm unable to find a clean solution for the simple example task of moving player While the input system generates key press events, I'm looking for a way to query the key state, since the player will most likely want to move the player for more than one frame. There are two possible ways I can think of solving this problem Retrigger the key press event every frame Pass the corresponding systems a reference to the input system Neither possibility sounds "correct", since they both require the abuse of the design. Is there a better approach for solving this issue?


Intersystem communication in a ECS game Apologies if this question has been answered before, but after relentless searching I couldn't find anything. As many, I've recently jumped on the ECS bandwagon, and I am currently killing some time by making a modest ECS game. The game is a somewhat simple 2D platform game. It is programmed in plain JS. The layout of the game is essentially as following The core of the game is the Engine, the Engine runs the game loop and holds an EventManager, responsible for raising events, and an EntityManager, responsible for containing all components of all entities. All logic is done by systems. The systems registers event handlers (i.e. member functions) with the EventHandler for specific EventTypes, which gets called when an event of that type is raised. For example this.eventManager.registerHandler(EventType.EVENT RENDER, this.render, null, this) I recently switched from calling all systems relevant functions explicitly in the Engine to this pattern. But over to my problem and question. For rendering I have a RenderSystem. This system contains references to several type of drawable animatable components which it, you guessed it, renders. Until recently, this system also contained a reference to another system, MapSystem, which spatially indexes all entities. The reason for this reference was to be able to call a function along the lines of mapSystem.search(frame bound) effectively pruning away all entities not needing to be rendered. So I have a couple of questions regarding this Is it very bad practice for systems to communicate directly? Something about it just doesn't smell right to me. I see how it might severely complicate your code if you have say 100 systems, and each system holds references to many of the other systems. Hello O(n 2). If I am not to hold inter system references, how do I perform communication like described above? My initial thoughts was to create an entity whose primary purpose were to hold the necessary information (i.e. all entities currently in the frame). Then let MapSystem write to and RenderSystem read from this entity. But this also seems to be rather unclean to me. Especially as MapSystems search function might be useful to call in many different contexts. Creating an entity per calling context doesn't really seem like a good way to go about it either. TL DR Is it bad for systems in a ECS game to communicate directly and hold references to each other?


Viewing one of multiple worlds in a component entity system? I've been working on a space simulation game. The player can control a ship and fly through wormholes to get from one solar system to another. I would like the player to be able to switch the camera view between the different solar systems they own something in (world, factories, defenses, etc). If am using just one component entity world then how do I tell the rendering system that looks for sprite components to only draw the sprite components of one solar system? I could add a "solar system id" field to each sprite component and have the rendering system check each component before rendering to make sure it's in the "active" solar system. It doesn't seem like a good idea though. Mostly because I'd be adding another if case before processing every single sprite, at the very least (other components may need similar checks). I could have the rendering system maintain an internal map of which solar system contains which entities, but then I have to write entity systems that keep track of all the entities, which is my entity system framework's job (Artemis for Java). Currently I am planning on making all of the solar systems separate from each other. They wouldn't exist in the same coordinate system. I suppose I could instead put everything on the same coordinate system and just move the camera around based on which solar system the player wanted to view at that time. The problem with that would be that my sprite rendering system would still be looping through all the sprites in the game, instead of just the ones at the active solar system. So, for lack of better options, I'm leaning toward using multiple component entity worlds. So each solar system would get its own set of systems (including the rendering system), and I'd set which one was active to enable the rendering systems for that solar system. I didn't want to take this approach for two reasons. First, it adds another layer of complexity on top of everything. Second, it seems like it might lessen some of the performance benefits (caching) of looping through all the same types of components and running the same entity system algorithm. Instead of doing a breadth first loop through all the components it would be more of a depth first loop through all the systems' components. So what is the best way to handle this?


Should fields in components in an ECS use polymorphism? I've just started to try and learn how to use ECS (Entity component systems), but I'm having trouble understanding the concepts behind components. Should adding more types of components, or trying to make a component reusable through its fields be favored? For example, if I'm trying to give all entities a shape for collision detection, should I have a different component for every shape (RectangleComponent, CircleComponent, PolygonComponent), or should I have one ShapeComponent, and in there have a field which is of type Shape, with class Shape having subclasses Rectangle, Circle, and Polygon. I'm unsure because using a Shape seems to be much more flexible and easier to implement systems, but it also feels like I'm violating the ECS rule of not having any functionality in components.


Ways to persist entities and components in an ECS? I am working on a small multiplayer game with rpg elements using java and quot Artemis ODB quot . Most of the logic is already done but one important thing is missing. The persistence. So i am searching for different ways to persist my game. One thing is important, the world is huge and i cant load in the whole world at once. I already stumbled upon two different ways on my own. Using a relational database or a nosql database. But one thing scares me... entity references. In my game i have an player entity and item entities. The player entity owns a inventory component which stores a reference to some item entities. In my ecs, each entity reference is an simple integer. So this looks like this... Represents the Inventory of our game, contains references to entities acting as items. public class Inventory extends HibernateComponent public Set lt Integer gt itemEntities new LinkedHashSet lt gt () Why does this scare me ? Well... Entity references are Integers in my case. They are no real ID and i cant set or change this quot ID quot of an entity because my framework permits it. This brings us straight to the problem. When i serialize this component or the whole player entity it would look like this. Inventory itemEntities 40,2,5,50 So when we save this and load it later on we have no entity with the id 40... and even if we recreate that entity we cant set it to an id of 40, because the frameworks permits it. So how the heck do we save references between entities ? So all in all... what are common ways to save, load entities from an ecs ? How do you do it ? And what would you recommend ?


How does an Engine like Source process entities? On the Source engine (and it's antecessor, goldsrc, quake's) the game objects are divided in two types, world and entities. The world is the map geometry and the entities are players, particles, sounds, scores, etc (for the Source Engine). Every entity has a think function, which do all the logic for that entity. So, if everything that needs to be processed comes from a base class with the think function, the game engine could store everything on a list and, on every frame, loop through it and call that function. On a first look, this idea is reasonable, but it can take too much resources, if the game has a lot of entities.. So, how does a engine like Source take care (process, update, draw, etc) of the game objects?


How to use batch rendering with an entity component system? I have an entity component system and a 2D rendering engine. Because I have a lot of repeating sprites (the entities are non animated, the background is tile based) I would really like to use batch rendering to reduce calls to the drawing routine. What would be the best way to integrate this with an engtity system? I thought about creating and populating the sprite batche every frame update, but that will probably be very slow. A better way would be to add a reference to an entity's quad to the sprite batch at initialization, but that would mean that the entity factory has to be aware of the Rendering System or that the sprite batch has to be a component of some Cache entity. One case violates encapsulation pretty heavily, while the other forces a non game object entity in the entity system, which I am not sure I like a lot. As for engine, I am using Love2D (Love2D website) and FEZ ( FEZ website) as entity system(so everything is in Lua). I am more interested in a generic pattern of how to properly implement that rather than a language library specific solution. Thanks in advance!


Multiple traversal of a component based hierarchy Let's say a game use a component based hierarchy to store all of its entities. So it can have objects, characters, lights organized in some kind of tree. When rendering the game, it needs to first render objects, then lights. So it needs to first traverse the hierarchy and render all the objects it finds, then traverse a second time to render all the lights it finds. What is a better way to do this? If the hierarchy has thousands of entities, it could be slow to traverse twice the tree. I thought about having two lists, one containing objects to render, the second one being lights. Each time the user adds an entity to the hierarchy, it adds it to the corresponding list. This way, the game only have to traverse the object list then the light list, without traversing useless entities. What is the best option?


Entity polymorphism and entity attributes I want to design the entity system of my game in a way such that entities are modular, easily modified without affecting other entities, and finally easy to add new types of entities. So ideally some version of component based design. In some parts of the code I want to deal with entities generally and abstractly, for example "update all entities" and "render all entities", however in other parts I want to deal with specific types of entity, like when a Soldier entity is fighting a Tank entity. The problem is some entities need attributes which others do not. For example a soldier needs HP but a missile do not. How do I keep entity attributes modular, and avoid adding every attribute in the game to the Entity object?


Multiple lua scripts using newthread I'm trying to hook lua scripts to my entities, where several entities of the same type want to use a separate instance of the same script. Problem is, when I run two or more scripts and use any C api functionality, I get an access violation after some time. I'm guessing some kind of stack corruption occurs but I'm not sure. The application is single threaded but uses lua newthread for each entity, and I then use lua resume on each new thread for when I want the scripts to run. The code looks like this. Script 1 function Update(dt, owner) print("Script 1") pos GetPosition(owner) end Script 2 function Update(dt, owner) print("Script 2") end GetPosition() static int GetPosition(lua State L) Core Entity entity lua tonumber(L, 1) Core TransformationComponent tc WGETC lt Core TransformationComponent gt (entity) lua newtable(L) for (int i 0 i lt 2 i ) lua pushnumber(L, tc gt position i ) lua rawseti(L, 2, i) return 1 How I create new lua threads (m luaState is the global parent state to which I bind all my functions) lua State LuaCore CreateThread(std string file) lua State newState lua newthread(m luaState) lua newtable(newState) new globals table lua newtable(newState) metatable lua pushliteral(newState, " index") lua pushvalue(newState, LUA GLOBALSINDEX) original globals lua settable(newState, 3) lua setmetatable(newState, 2) lua replace(newState, LUA GLOBALSINDEX) replace newState's globals luaL dofile(newState, file.c str()) return newState How each script is called lua State ls GetChildState(stateIndex) lua pushstring(ls, functionName.c str()) lua gettable(ls, LUA GLOBALSINDEX) SimpleLuaCallData slcd (SimpleLuaCallData )inData lua pushnumber(ls, slcd gt dt) lua pushnumber(ls, slcd gt ownerID) lua pcall(ls, 2, 0, 0) return nullptr If I remove the call to GetPosition from Script 1, the application runs without issue. Am I missing some kind of required clean up or garbage collection problems? I'd like to try and avoid creating a new state for each entity, as that seems excessive and sharing globals via the core state is nice. lua pcall doesn't produce any results. The application eventually stops running Script 1 and after a few more cycles it gets the access violation on lua gettable(ls, LUA GLOBALSINDEX) in the calling function.


How can I efficiently implement a bitmask larger than 64 bits for component existence checks? In my ECS implementation, I use bit wise operations (as described and illustrated in this thread) to tell an entity what type of components it currently consists of. So my Entity class has the following member unsigned long m CompMask The different component types are then defined as an enum, whose member values are all power of two enum ComponentType COMP TYPE UNKNOWN 0, COMP TYPE PERSON 1, COMP TYPE RENDERABLE 2, COMP TYPE MOVEABLE 4, ... Each time a new component is added to my entity instance, I do the following bit operation to update the mask (where newType is a member of the enum mentioned above) m CompMask newType This approach enables me to efficiently check if a certain entity instance has a certain component (and hence might be relevant for a specific system), like so return (m CompMask amp type) The limiting factor in this approach however is the m CompMask variable since it won't be able to handle more than 64 component types (if I increase it to unsigned long long). I don't expect to be needing more than that in my current project, but nonetheless I'd like to hear some ideas regarding alternatives that allow more than 64 types (as big games certainly need to) while still maintaining the ease and efficiently of those bit wise operations as much as possible? Any ideas how this is handled in "proper big" projects?


Why is it a bad idea to store methods in Entities and Components? (Along with some other Entity System questions.) This is a followup to this question, which I answered, but this one tackles with a much more specific subject. This answer helped me understand Entity Systems even better than the article. I've read the (yes, the) article about Entity Systems, and it told me the following Entities are just an id and an array of components (the articles says that storing entities in components isn't a good way of doing things, but doesn't provide an alternative). Components are pieces of data, that indicate what can be done with a certain entity. Systems are the "methods", they perform manipulation of data on entities. This seems really practical in many situations, but the part about components being just data classes is bothering me. For example, how could I implement my Vector2D class (Position) in an Entity System? The Vector2D class holds data x and y coordinates, but it also has methods, which are crucial to its usefulness and distinguish the class from just a two element array. Example methods are add(), rotate(point, r, angle), substract(), normalize(), and all other standard, useful, and absolutely needed methods that positions (which are instances of the Vector2D class) should have. If the component was just a data holder, it wouldn't be able to have these methods! One solution that could probably pop up would be to implement them inside systems, but that seems very counter intuitive. These methods are things that I want to perform now, have them be complete and ready to use. I don't want to wait for the MovementSystem to read some expensive set of messages that instruct it to perform a calculation on the position of an entity! And, the article very clearly states that only systems should have any functionality, and the only explanation for that, which I could find, was "to avoid OOP". First of all, I don't understand why should I refrain from using methods in entities and components. The memory overhead is practically the same, and when coupled with systems these should be very easy to implement and combine in interesting ways. The systems, for example, could only provide basic logic to entities components, which know the implementation themselves. If you ask me this is basically taking the goodies from both ES and OOP, something that can't be done according to the author of the article, but to me seems like a good practice. Think about it this way there are many different types of drawable objects in a game. Plain old images, animations (update(), getCurrentFrame(), etc), combinations of these primitive types, and all of them could simply provide a draw() method to the render system, which then doesn't need to care about how the sprite of an entity is implemented, only about the interface (draw) and the position. And then, I would only need an animation system which would call animation specific methods that have nothing to do with the rendering. And just one other thing... Is there really an alternative to arrays when it comes to storing components? I see no other place for components to be stored other than arrays inside an Entity class... Maybe, this is a better approach store components as simple properties of entities. For example, a position component would be glued to entity.position. The only other way would be to have some kind of a strange lookup table inside systems, that references different entities. But that seems very inefficient and more complicated to develop than simply storing components in the entity.


How do I go about creating the "Watcher" component? Last weekend, I spent several hours writing a basic entity component model, in JavaScript. I was largely referencing the Ash Actionscript game engine. I successfully worked out how the systems, components, nodes, and entities all link up, but one thing that eludes me is how to implement the "watcher" that checks the entities for their components, creates nodes for them, adds those nodes to the various systems automatically, and watches for any changes in the components on an entity. I was a bit confused by the way it works, in Ash, and all of the posts and tutorials on the subject that I have read seem to forgo the details of that part of the implementation. Right now, I currently have the following Entity, which is assigned components. Engine, which keeps a track of the systems and entities. Node, which contains references to the components in an entity that we want the system to modify (I am currently creating these, manually, and adding it to the system). Component, which contains the data to be modified by the system. System, which operates on the nodes, which in turn change the data in the entity. I also have various other classes, dedicated to holding lists of the various objects. How do I go about creating the "Watcher" component?


Superclassing RPG Game Entities I am in the design process of an RPG game and I have no experience at all in game dev. This question is about how I should approach entity management using OOP classes. My train of thought is as followed Have Entity interface with basic update() function "Mortal" class and "NPC" class implement Entity "Hero" and "Monster" class inherit from "Mortal" class In this case, Mortal class are all those entities that have statuses such as HP and MP. NPC are self explanatory. I am sure my approach is naive so I would like to know the pros and cons and what would be a better way to approach this.


State Screen management in Entity Component Systems My entity component system is happily humming along and, despite some performance concerns I initially had, everything is working fine. However, I've realized that I missed a crucial point when starting this thing how do you handle different screens? At the moment, I have a GameManager class which owns a component manager and entity manager. When I create an entity, the entity manager assigns it an ID and makes sure it's tracked. When I modify the components that are assigned to an entity. an UpdateEntity method is called, which alerts each of the systems that they may need to add or remove the entity from their respective entity lists. A problem with this is that the collection of entities operated on by each system is determined solely by the individual Systems, typically based on a "required component" filter. (An entity has to have a Renderable component to be rendered, for instance.) In this situation, I can't just keep collections of entities per screen and only Update Draw those collections. They'd have to either be added and removed depending on their applicability to the current screen, which would cause their associated components to be removed, or enable disable entities in a group per screen to hide what's not supposed to be visible. These approaches seem like really, really crappy kludges. What's a good way to handle this? A pretty straightforward way that comes to mind is to create a separate GameManager (which in my implementation owns all of the systems, entities, etc.) per screen, which means that everything outside of the device context would be duplicated. That's bothersome because some things are always visible, or I might want to continue to display the game under a translucent menu window. Another option would be to add a "layer" key to the GameManager class, which could be checked against a displayable layer stack held by the game manager. System.Draw() would be called for each active layer, in the required order as determined by the stack. When the systems request an iterator for their respective entity collections, it would be pre filtered to a (cached) set of those entities that participate in the active layer. Those collections could be updated from the same UpdateEntity event that's already used to maintain each system's entity collections. Still, kinda feels like a hack. If I've coded myself into a corner, feel free to throw tomatoes as long as they're labeled with a helpful suggestion. Hooray for learning curves.


Point welding on generated terrain I am converting two 2D images (A Voronoi graph and a Diamond Square noise map) into a 3D object. However when finding the corner points of the Voronoi I am left with gaps, so I thought to drop these by calculating adjacency to existing nodes before creating the vertex. However no matter which algorithm for the weld I use, or the tolerance level of the distance I can't seem to get it to work. This has led me to believe I am doing something wrong. Image of the issue These gaps do not appear if I run without the weld, they are created by the weld jumping to spots, but then later welds not finding that spot. I have even tried to increment the weld distance to a maximum of 10, if a suitable node wasn't found. But this is far to aggressive and has the effect of simplifying the mesh instead and creating more gaps. My Repo for the full code is here https github.com HughAJWood TerrainGenerator private void CalculatePolys() var nodesForEdges new List lt VNode gt () foreach (var region in regions) foreach (var point in region) if (point null) continue We calculate where the voronoi node corners are, and pass them into the region var diff ColoursDifferent(point) if (diff gt 1) RenderNodePointsOnImage(point) Points are 2D, so to translate to 3D they are set to the Z property of the 3D node var node new VNode X point.X, Z point.Y Weld points within 1 unit from each other by determining if we already have one that exists then using the existing node instead A weld is calculated by determining the X,Z distance to see if we have a node stored already that is within 2 units of the node we are creating VNode existingNode Nodes.FirstOrDefault(n gt n.Adjacent(node)) if (existingNode null) Optimise node creation by skipping perlin lookup and ID iteration for only when needed node.ID VNodeId node.Y perlin.GetPixel(point.X, point.Y).R Nodes.Add(node) Mesh.ControlPoints.Add(new Vector4(node.X, node.Y, node.Z, 1)) else node existingNode nodesForEdges.Add(node) if (i gt 20) return AddNodesToMeshAsPolys(nodesForEdges) nodesForEdges.Clear() The adjacency method is currently simplified to the fact I want to ignore the height of the node. internal static bool Adjacent(this VNode a, VNode b, int tolerance 3) var distance Math.Abs(a.X b.X) Math.Abs(a.Z b.Z) return distance lt tolerance UPDATE I have tried sorting the points by distance and fuzzy distance, both sort in the correct order. Then I tried taking the first point and using that as the welding point. Same effect. I tried to average the points at the intersections at the image level and pass that back as the point every time, then weld. Same effect. Clearly there are many approaches I can take for this, the problem arises when there are 2 points close to each other on the edge of a voronoi region. Sometimes they weld and create a gap. Sometimes however in some variances of the algorithm that the points don't weld even though their X,Z coordinates are very close to each. I'm still stumped as how to approach this.


Polygon count target range for MMO being released in 2 years What would a realistic poly count target range be for NPC and player models in a 3D MMO that will be released in 2 years? What about poly count target range for the entire camera view (environment, NPC and player meshes)? I read in some places that one should not aim too low if the game will come out in a couple years because technology is always advancing. If you can give some mesh poly stats on what other current MMOs MMORPGs are running and future projections, that would be great. Thank you.


How to convert an octree to a polygon mesh? So if I have dynamic voxel terrain data stored in an octree representation what would be the best way to go about converting the octree to a polygon mesh which I can render with OpenGL? A lot of the meshing algorithms I have found online assume that voxel data is stored in a 3D Array however for the level of detail I am using storing chunk data in a massive array isn't really an option (chunk size 64x1024x64 with each block roughly 4bytes) split into several 64x64x64 small octrees, I could make the chunk size smaller but then that means more draw calls etc. Basic searches on google for 'meshing an octree' seem to bring up lots of research on doing the inverse (converting from meshes to SVOs). The problem with using these algorithms on the octree instead of the array is that the octree has a much slower access time not to mention the time cost of copying the data from the octree representation. I have considered the possibility of converting to an RLE or spatial hashing system but these two systems both have their drawbacks especially since I plan to use the same octree when I come to implement collision detection. I would guess that it would be best to traverse down the tree rather than iterating over it like an array, but some more ideas about how I could optimise this would be appreciated.


Simulate dirt spread (Normal distribution?) This question is technically more math related, but it has to do with a simulation so I am here first. I can post this in the math SE instead if needed. I am in the process of trying out some mesh deformation simulating the effect of sand dirt being poured in a pile (Think hourglass sand) and I am trying to determine the best way to calculate the spread instead of becoming increasingly taller. I don't intend on actually matching sand dirt physics, I just want to get my mesh to be somewhat close to the shape that pile would make as it grows. I'm pretty sure that Normal Distribution is what I want, so in my desmos graph below, think of f(x) green line as the current dirt sand piling up (where I am at in my code) and f1(x) purple line as the spread version (what I want to happen instead). f1(x) is not correct but I think it is pretty close. Essentially i need the area of f1(x) to always equal the area of f(x) but as f(x) gets taller, f1(x) gets wider and taller, but not as tall as f(x). https www.desmos.com calculator ir8if2u8qq lt a title "View with the Desmos Graphing Calculator" href "https www.desmos.com calculator ir8if2u8qq" gt lt img src "https s3.amazonaws.com calc thumbs production ir8if2u8qq.png" width "200px" height "200px" style "border 1px solid ccc border radius 5px" gt lt a gt I hope this makes sense to you gurus. If not, I can try to clarify more. Edit Also, if you open that graph, the slider for variable 'h' is the one im essentially trying to work with.


How can I produce 3D environments for VR from HDRI images? I have a question regarding to the HDRI maps as many some of you have a bit of experience in this field especially for Oculus Rift platform! I've been trying to achieve a 3D landscape from this HDRI map. (Also I highly recommend this website for others )!) I even decided to render in Maya few images from the orthographic perspective but unfortunately still no luck. See the results here on YouTube. Is there any other method to reconstruct 3D models just from images and use them to create environment?


Does it make sense to use voxel editors only for meshing? I am a hobbyist game developer. If there is something that I really don't like is 3D modeling, in particular all the work that needs to be put in the "pipeline" for the creation of models, in particular UV mapping. Remembering games like Minecraft or "Little big planet", I was wondering if voxel editors could be used for just modeling let me explain using a voxel editor to make each object I need for my games and then export them singularly as FBX with either marching cubes or even better dual contouring for meshing. Does an approach like this make sense in terms of performance? From what I can tell, I would need a voxel software which allows all of the following criteria. Dual contouring meshing FBX or OBJ export of meshed area Multiple materials Now, it looks like such software doesn't exist, which makes me think that this approach for 3D modeling may be totally wrong. Any heads up on this?


matrix to transform unit cube to space defined by 8 arbitrary points I asked a question relating to similar to this already, but I think this is a clearer objective of what Im trying to achieve.. or whether its possible at all! Im trying to find a transformation (matrix ideally) which would transform the 8 points of a 3d unit cube to 8 arbitrary points in space. The 8 target points have no known structure. e.g My gut feeling is that a matrix is unable to provide this xform since the cube faces vertices can be concave.. but are there any other methods of transformation? Thanks!


Vertex Normals, Loading Mesh Data My test FBX mesh is a cube. From what I surmise, it seems that the cube is on the extreme end of this issue, but I believe that the same issue would be able to occur in any mesh Each vertex has 3 normals, each pointing a different direction. Of course loading in any type of mesh, potentially ones having thousands of vertices, I need to use indices and not duplicate shared verts. Currently, I'm just writing the normals to the vertex at the index that the FBX data tells me they go to, which has the effect of overwriting any previous normal data. But for lighting calculations I need more info, something that's equivalent to a normal per face, but I have no idea how this should be done. Do I average the 3 different verts' normals together or what?


Identifying mesh format from initial bytes I have a file containing mesh data whose blocks seem to start with DWORDS like 0x1 0x1 0x3100026f 0x1 0x30000112 or 0x1 0x1 0x310007b2 0x1 0x30000112 or 0x10000006 0x3 0x310001f6 0x310001f6 0x310001f6 They don't look like .x binaries. Any other ideas? UPDATE Here's more 00000001 00000001 3100026F 00000001 30000112 000000C7 BD869270 3F0372D4 00000000 BD41F15F 3F11A611 3F522E05 3E40EF5A 3E17CDF8 3E40993C BF504FBD 3F0CCC2A BF78001B BE654B6A 3DDA7965 BD80EB99 3F003679 3C0BDAE1 BD3DD880 3F112A76 3F528732 3E8EFD04 3E185DD8 3E3984B8 BF48A923 3F180DA9 BF7854DC BE6599AE 3DBF7319 BCD7235C 3F041CCC 00000000 BF52314E 3F12223D 00000000 3F727B04 3C22FD80 3E29BCD1 3F7C0367 3D6FCD12 3E70A826 BCE91707 BF78B921 BCD7235C 3F008C87 3C28E0F6 BF6B36D8 3BD28E32 3ECA109F 3F4AEA89 3D894EC0 BE18A98D 3F7CC7A8 3D57AE4B 3E48D2F6 B46C577B 3F7B0753 BE3DBAC2 3EF41E67 It looks like some of these are almost certainly floats and others are almost certainly not. And it appears (not shown here) that after a long list of valid floats, there is a long list of DWORDS that aren't valid floats. A list of vertices followed by some table of indices?


Calculating vertex normals to be able to have both sharp edges and smooth gradients I'm computing area weighted vertex normals, but lighting looks bad on meshes containing sharp edges and corners (e.g. cubes look 'blobby' as the light leaks onto the dark sides). Is there a way of calculating using vertex normals to preserve sharp edges and still have smooth regions? Ideally, without the need to create extra geometry (e.g. splitting faces adjacent to a sharp edge and creating new vertices). Most sources talk about having different 'smoothing groups' which influence geometry generation. Could someone explain what are "per corner" normals? From Libigl tutorial "Storing normals per corner is an efficient and convenient way of supporting both smooth and sharp (e.g. creases and corners) rendering."