_id
int64
0
49
text
stringlengths
71
4.19k
44
How to know if an overriden method calls its super method or not? Consider this situation, where a Player class inherits from a more general Actor class Actor.gd class name Actor extends KinematicBody2D func ready() print( quot I am an actor quot ) foo() func foo() print( quot I was thinking I was an actor quot ) Player.gd class name Player extends Actor func ready() print( quot I am a player quot ) func foo() print( quot I was thinking I was a player quot ) When one instantiate a player in a scene, we have this output I am an actor I was thinking I was a player I am a player How to know when a method will call its super class?
44
Inverse Distance Weighted interpolation between N Vector3s in Godot I have a number of Vector3s in Godot arranged in a grid, let's say they look like this (looking at them from above, with Godot Y is up) z (0,6,2) (1,5,2) (2,3,2) (0,2,1) (1,A,1) (2,3,1) (0,2,0) (1,3,0) (2,4,0) x I would like to interpolate the center Y value marked as A based on the surrounding vectors. The thing is, the center value is not bound to the grid, so it can be closer to the lower left corner for example, so I want to weight the interpolated value based on the distance to each vector. So, is there some clever trick in Godot using built in functions, or do I need to implement my own Inverse Distance Weighting code?
45
What are the most common ways of closing an open world? In many open world games, there are several ways to limit them. From original ones such as Desynchronisation(Assasins' Creed) to invisible walls. What are the most common ways to close open worlds?
45
how large should a map be in blender I'm learning blender and am wondering what size(blender units) I should be making my characters and maps. should i consider 1 blender unit as 1 inch, foot, meter or does it not not matter?
45
Is there any way to convert .unr file? I'd like to examine a Harry Potter game for study purposes. All of resources are fine except map file. The maps are in a .unr file format. I know it is unreal map file. Is there any way to convert .unr file to .fbx, .obj, or pskx formats? I want to open map file to 3ds max or blender.
45
How do I show the current view from the viewport on my map? I'm doing HTML5 Canvas development and currently have a large viewport (on the left) and a map (on the right). Like this I need to show on the map what is currently being viewed in the left. And I'm at a lost on how to calculate this. This is how I want it to be I am manipulating the main viewport via a transformation matrix. like 1, 0, 0, 1, 0, 0 This is decently common functionality in different games and apps. So I assume there are resources on how to do it. But I haven't been able to find any.
45
Level Map file creation and processing with OpenGL How do levels maps work in the game development world? Counter strike, which is a popular FPS that uses OpenGL as it's graphics library, has it's levels maps created as .bsp files. How do you create files like this, and use OpenGL to load them? Thanks!
45
How to write a custom map canvas and project coordinates on it? I am writing a game with Objective C ( xcode ) and I need to use the users location service to mark their position on a map but since I need to create my own map component, I am not able to use the Map framework. Doing this I think I need to project latitude and longitude which I receive from location framework on my custom planar canvas, this is a small part of my game but the other parts are pretty easy or could be done if I could manage to implement this part, however I dont know where to start. did anybody does it before? is it easy to create a map canvas? Any kind of hint and help or sympathy are welcome. Thanks
45
Generating a map in runtime for a simple top scrolling racing game I'm creating a simple top scrolling racing game. The concept is quite simple the player controls the car, which goes on a dynamically generated field with square blocks. Once the car hits a car, the game ends. My first implementation was simply to put a few random blocks in each row being generated on the top of the screen, but this does lead to maps where going through is impossible. What is the best algorithm for generating such type maps? My platform of choice is XNA and C , if that's important. EDIT Here's an illustration (pic) In this case, there's no possible way for the player to pass.
45
Best way to solve tile drawing in 2D side scroller? What i still can't figure out is which would be the more sane way easier and faster way to draw the map on the screen.. I mean i will use many tiles for my maps in my side scroller.. But problem is should i make the maps in whole images like one .png file for each map (Example) or should i draw the tiles by code like a for loop in c .. Which way is most recomended or where can i read about which way is the best.
45
What kind of environment is expected in elevated, hot areas? I'm creating an "exploration" game where the overworld map will be randomly generated. The biomes are generated using the data given by a "temperature map" , a "humidity map", and an elevation map for instance cold humidity snow, hot humidity jungle, etc The problem I'm left with is how to deal with elevated zones in hot climate. Right now it is set to the "bare" biome (the gray areas in the following pic), which I guess is supposed to mean "deserted dry land". On the other hand, elevated zones with colder temperatures is set to snow (in white), which is ok. So, how should I deal with the elevated zones in cold climate? I have several ideas but I feel that none of them works 1) set it to snow as well, but I think it would feel weird 2) set it to "bare" but I don't think it actually exists IRL or that i'd have any interesting gameplay perspectives
46
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?
46
How to prevent attackers from compromising multiplayer game servers? Consider a relatively small multiplayer game server, written by an individual or a small company. Some malicious user wants to boost their character stats by a factor of 100. What paths of attack might they have and what are the most important safeguards to prevent these attacks?
46
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?
46
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.
46
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?
46
Saving game data to server What's the best method to save the player's data to the server? Method to store the game saves Which one of the following method should I use ? Using a database structure(e.g.. mySQL) to store the game data as blobs? Using the server hard disk to store the saved game data as binary data files? Method to send saved game data to server What method should I use ? socketIO web socket a web based scripting language to receive the game data as binary? for example, a php script to handle binary data and save it to file Meta data I read that some games store saved game meta data in database structures. What kind of meta data is useful to store? Edit 1 This question was to actually see what technology is better to use based on the situation. The situation is a game that will be on cross platform, save game throughout the cloud. Method of delivery from game client(iOS, Android, Windows Phone 8, etc..) to game server(Linux, Windows, etc.) Im using a Ubuntu server at this moment. Method of storage of binary data Inside a database system or file system. The up and down side to it and the community options of existing structures. Storing of meta data Well, I'm not too sure about how to store saved game data to server at the moment. Thus, was wondering if the community can provides tried and tested methods used by the community. and their preferences.
46
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?
46
How to split login and game logic when writing servers? I'm building a poker like game server, I was going to have all logins and game logic to be handled on one server, but from my research on the web, I learn that this would not scale, and it would make sense to split the work into a login and game servers. But what I don't get is after I handled authentication in the login server, and have the client make a new connection to the game server, how would I know which client is which? Would I not have to re login again and thus defeat the purpose of having a server for login? Is there some way to pass a connection across processes and machines that I don't know about? Excuse my little knowledge of networking.
46
When to read write to database with a game server My question is fairly simple but maybe hard to answer. I'm currently building my own game server and I've done to login server now. So, on to the actual game server. I have a question for this server though. Say, a thousand players are moving around on this server, how do I manage this with the database (MySQL) that should hold the player positions and such? I understand I can't query the database every time something small changes or a single player moves because that would be a huge load for that server. How is this done in real game servers? When do they read or write to the database?
46
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)
46
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?
46
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?
47
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?
47
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 ?
47
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?
47
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?
47
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.
47
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
47
User friendly scripting when using an ECS? I am currently creating a small hobby project to get back into game development, and I have decided to structure my entities using an ECS (Entity Component System). This implementation of an ECS is structured like so Entity In my case it's a unique int identifier that is used as a key to a list of components. Component Holds only data, e.g. the Position component holds an x and y coordinate, and the Movement component holds a speed and direction variable. System Handles components, e.g. it takes the Position and Movement components and adds the speed and direction to the position's x and y coordinates. This works fine, but now I wish to implement scripting into my games, in the form of a scripting language. In previous projects I've used an OOP implementation of game objects, which meant that scripting was pretty straight forwards. For example, a simple script could look something like this function start() local future entity moveTo(pos1) wait(future) local response entity showDialog(dialog1) if wait(response) 1 then local itemStack entity getInventory() removeItemByName("apple", 1) world getPlayer() getInventory() addItemStack(itemStack) else entity setBehavior(world getPlayer(), BEHAVIOR HOSTILE) end end However, when using an ECS, the entity itself does not have any functions like moveTo or getInventory, instead the above script written in ECS style would look something like this function start() local movement world getComponent(MOVEMENT, entity) movement moveTo(pos1) local position world getComponent(POSITION, entity) local future Future untilEquals(position.pos, pos1) wait(future) local dialogComp world getComponent(DIALOG, entity) local response dialogComp showDialog(dialog1) if wait(response) 1 then local entityInventory world getComponent(INVENTORY, entity) local playerInventory world getComponent(INVENTORY, world getPlayer()) local itemStack entityInventory removeItemByName("apple", 1) playerInventory addItemStack(itemStack) else local entityBehavior world getComponent(BEHAVIOR, entity) local playerBehavior world getComponent(BEHAVIOR, world getPlayer()) entityBehavior set(playerBehavior, BEHAVIOR HOSTILE) end end This is a lot more verbose compared to the OOP version, which is not desirable when the scripting is aimed towards mostly non programmers (players of the game). One solution would be to have some sort of wrapper object that encapsulates an Entity and supplies functions such as moveTo directly, and handles the rest internally, although such a solution seems sub optimal since it takes a lot of work to cover all the components, and every time a new component is added you would need to change the wrapper object with new functions. To all game developers that has implemented scripting in an ECS before how did you do it? The main focus here is usability for the end user, with as little "maintenance" cost as possible (preferably you don't need to change it every time you add a component).
47
Organizing an entity system with external component managers? I'm designing a game engine for a top down multiplayer 2D shooter game, which I want to be reasonably reuseable for other top down shooter games. At the moment I'm thinking about how something like an entity system in it should be designed. First I thought about this I have a class called EntityManager. It should implement a method called Update and another one called Draw. The reason for me separating Logic and Rendering is because then I can omit the Draw method if running a standalone server. EntityManager owns a list of objects of type BaseEntity. Each entity owns a list of components such as EntityModel (the drawable representation of an entity), EntityNetworkInterface, and EntityPhysicalBody. EntityManager also owns a list of component managers like EntityRenderManager, EntityNetworkManager and EntityPhysicsManager. Each component manager keeps references to the entity components. There are various reasons for moving this code out of the entity's own class and do it collectively instead. For example, I'm using an external physics library, Box2D, for the game. In Box2D, you first add the bodies and shapes to a world (owned by the EntityPhysicsManager in this case) and add collision callbacks (which would be dispatched to the entity object itself in my system). Then you run a function which simulates everything in the system. I find it hard to find a better solution to do this than doing it in an external component manager like this. Entity creation is done like this EntityManager implements the method RegisterEntity(entityClass, factory) which registers how to create an entity of that class. It also implements the method CreateEntity(entityClass) which would return an object of type BaseEntity. Now comes my problem How would the reference to a component be registered to the component managers? I have no idea how I would reference the component managers from a factory closure.
47
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?
47
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?
47
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
47
Communicating with Collision System in ECS I have read tons of articles and forums threads about ECS but still can't understand how anything in engine should communicate with Collision System. Let's say I have Input System that handle keyboard input and then at some point it want to move player character forward. Before doing this I should ask Collision System if there would be a collisions after that move and only if no change position. My current approach is to have requestTranslation function in CollisionSystem that take translation function and object like this moveForward() V3.CollisionSystem.requestTranslation(this.mesh, function(object) object.translateZ( this.movingSpeed) .bind(this)) What do you think about this approach? How good bad it is? What are know alternatives?
47
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?
47
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?
47
Efficiently separating Read Compute Write steps for concurrent processing of entities in Entity Component systems Setup I have an entity component architecture where Entities can have a set of attributes (which are pure data with no behavior) and there exist systems that run the entity logic which act on that data. Essentially, in somewhat pseudo code Entity id map lt id type, Attribute gt attributes System update() vector lt Entity gt entities A system that just moves along all entities at a constant rate might be MovementSystem extends System update() for each entity in entities position entity.attributes "position" position vec3(1,1,1) Essentially, I'm trying to parallelise update() as efficiently as possible. This can be done by running entire systems in parallel, or by giving each update() of one system a couple of components so different threads can execute the update of the same system, but for a different subset of entities registered with that system. Problem In the case of the shown MovementSystem, parallelization is trivial. Since entities don't depend on each other, and don't modify shared data, we could just move all entities in parallel. However, these systems sometimes require that entities interact with (read write data from to) each other, sometimes within the same system, but often between different systems that depend on each other. For example, in a physics system sometimes entities may interact with each other. Two objects collide, their positions, velocities and other attributes are read from them, are updated, and then the updated attributes are written back to both entities. And before the rendering system in the engine can start rendering entities, it has to wait for other systems to complete execution to ensure that all relevant attributes are what they need to be. If we try to blindly parallelize this, it will lead to classical race conditions where different systems may read and modify data at the same time. Ideally, there would exist a solution where all systems may read data from any entities it wishes to, without having to worry about other systems modifying that same data at the same time, and without having the programmer care about properly ordering the execution and parallelization of these systems manually (which may sometimes not even be possible). In a basic implementation, this could be achieved by just putting all data reads and writes in critical sections (guarding them with mutexes). But this induces a large amount of runtime overhead and is probably not suitable for performance sensitive applications. Solution? In my thinking, a possible solution would be a system where reading updating and writing of data is separated, so that in one expensive phase, systems only read data and compute what they need to compute, somehow cache the results, and then write all the changed data back to the target entities in a separate writing pass. All systems would act on the data in the state that it was in at the beginning of the frame, and then before the end of the frame, when all systems have finished updating, a serialized writing pass happens where the cached results from all the different systems are iterated through and written back to the target entities. This is based on the (maybe wrong?) idea that the easy parallelization win could be big enough to outdo the cost (both in terms of runtime performance as well a code overhead) of the result caching and the writing pass. The Question How might such a system be implemented to achieve optimal performance? What are the implementation details of such a system and what are the prerequisites for an Entity Component system that wants to use this solution?
47
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?
47
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?
47
Efficiently separating Read Compute Write steps for concurrent processing of entities in Entity Component systems Setup I have an entity component architecture where Entities can have a set of attributes (which are pure data with no behavior) and there exist systems that run the entity logic which act on that data. Essentially, in somewhat pseudo code Entity id map lt id type, Attribute gt attributes System update() vector lt Entity gt entities A system that just moves along all entities at a constant rate might be MovementSystem extends System update() for each entity in entities position entity.attributes "position" position vec3(1,1,1) Essentially, I'm trying to parallelise update() as efficiently as possible. This can be done by running entire systems in parallel, or by giving each update() of one system a couple of components so different threads can execute the update of the same system, but for a different subset of entities registered with that system. Problem In the case of the shown MovementSystem, parallelization is trivial. Since entities don't depend on each other, and don't modify shared data, we could just move all entities in parallel. However, these systems sometimes require that entities interact with (read write data from to) each other, sometimes within the same system, but often between different systems that depend on each other. For example, in a physics system sometimes entities may interact with each other. Two objects collide, their positions, velocities and other attributes are read from them, are updated, and then the updated attributes are written back to both entities. And before the rendering system in the engine can start rendering entities, it has to wait for other systems to complete execution to ensure that all relevant attributes are what they need to be. If we try to blindly parallelize this, it will lead to classical race conditions where different systems may read and modify data at the same time. Ideally, there would exist a solution where all systems may read data from any entities it wishes to, without having to worry about other systems modifying that same data at the same time, and without having the programmer care about properly ordering the execution and parallelization of these systems manually (which may sometimes not even be possible). In a basic implementation, this could be achieved by just putting all data reads and writes in critical sections (guarding them with mutexes). But this induces a large amount of runtime overhead and is probably not suitable for performance sensitive applications. Solution? In my thinking, a possible solution would be a system where reading updating and writing of data is separated, so that in one expensive phase, systems only read data and compute what they need to compute, somehow cache the results, and then write all the changed data back to the target entities in a separate writing pass. All systems would act on the data in the state that it was in at the beginning of the frame, and then before the end of the frame, when all systems have finished updating, a serialized writing pass happens where the cached results from all the different systems are iterated through and written back to the target entities. This is based on the (maybe wrong?) idea that the easy parallelization win could be big enough to outdo the cost (both in terms of runtime performance as well a code overhead) of the result caching and the writing pass. The Question How might such a system be implemented to achieve optimal performance? What are the implementation details of such a system and what are the prerequisites for an Entity Component system that wants to use this solution?
47
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.
47
System function in entity component architecture I started working with ECS and I am not completely sure that I understand it correctly. As I see it now systems can implement logic for collision, movement, similar things like that. But would it be correct to dedicate a system for digging game logic only? It has a method for dig action, it also sets animation component to play "dig" animation and listens for event about animation completion after which it executes dig action. Am I doing it right?
47
How can I provide attribute extensibility in a component based entity system? This question and its answers move against utilizing an entity component system where the component itself is just a generic class with an dynamic container for the attributes properties of the component. Some definitions for this thread Entity ID collection of components Component Container (std map lt attribute name, attribute value gt ) of attributes properties, such as health, age, name, gender, etc. I understand and am aware of the drawbacks (no compile time type safety, added overhead of looking up values from the container). Nonetheless, I currently am working on with such a system, with the following argument, which I would now like to put to the test data driven design. If all the attributes of the component are in a dynamic container, it is very easy (in fact possible at all) to add new ones later on, outside of the source code. So you can easily script new attributes later on. And dumping saving the state of the component is a piece of cake. Compared to the proposal in the above mentioned thread, I also have an own class for each component, to implement some basic behavior and helper methods directly in them (but those also need to look up their values from the container). Example My component base class has a map for all the attributes property typedef std map lt std string, PropertyBase gt PropertyMap So an actual component looks something like the following. In the constructor I populate the attributes I want the component to have, by adding them to the map. Later I can read and update them if needed, but always with a performance penalty, since I first have to find them in the std map. class Person public ClonableComponent lt Person gt public Person(ComponentFactory const pFactory, ComponentType type, ComponentID id, GameEntity const pEntity) ClonableComponent(pFactory, type, id, pEntity) General addProperty(new Property lt int gt ("age", PROP INT, 0)) addProperty(new Property lt String gt ("gender", PROP STRING, "unknown")) addProperty(new Property lt String gt ("currentLocation", PROP STRING, "unknown")) Feelings addProperty(new Property lt bool gt ("isTired", PROP BOOL, false)) addProperty(new Property lt bool gt ("isHungry", PROP BOOL, false)) addProperty(new Property lt bool gt ("isThursty", PROP BOOL, false)) void enterLocation(GameEntity pLocGE) if(pLocGE gt hasComponent(COMP TYPE LOCATION)) updateProperty("currentLocation", pLocGE gt getName()) updateProperty("casinoEnteredDateTime", (int)std time(0)) void leaveLocation() updateProperty("currentLocation", std string("unknown")) However, that thread made me think, and I am now doubtful that my approach will work well in the long run (maintenance, scaling and performance wise) and I am therefore considering moving to an directly typed approach with no look up overhead. At the same time I don't want to loose that data driven extendability. I thought of a hybrid approach Keep all known variables as actual language variables but also add a container (std map) for scripted data driven variables. Therefore I'd know that my internal access is very fast and only the later added scripted extension would have the slow look up and the other mentioned penalties. Question What do you use would propose as an approach for a data driven ECS in terms of attribute storage handling? How do you keep it extendable? Would you recommend such a hybrid approach (real variables internally, container for new, external definitions)?
47
Efficiently separating Read Compute Write steps for concurrent processing of entities in Entity Component systems Setup I have an entity component architecture where Entities can have a set of attributes (which are pure data with no behavior) and there exist systems that run the entity logic which act on that data. Essentially, in somewhat pseudo code Entity id map lt id type, Attribute gt attributes System update() vector lt Entity gt entities A system that just moves along all entities at a constant rate might be MovementSystem extends System update() for each entity in entities position entity.attributes "position" position vec3(1,1,1) Essentially, I'm trying to parallelise update() as efficiently as possible. This can be done by running entire systems in parallel, or by giving each update() of one system a couple of components so different threads can execute the update of the same system, but for a different subset of entities registered with that system. Problem In the case of the shown MovementSystem, parallelization is trivial. Since entities don't depend on each other, and don't modify shared data, we could just move all entities in parallel. However, these systems sometimes require that entities interact with (read write data from to) each other, sometimes within the same system, but often between different systems that depend on each other. For example, in a physics system sometimes entities may interact with each other. Two objects collide, their positions, velocities and other attributes are read from them, are updated, and then the updated attributes are written back to both entities. And before the rendering system in the engine can start rendering entities, it has to wait for other systems to complete execution to ensure that all relevant attributes are what they need to be. If we try to blindly parallelize this, it will lead to classical race conditions where different systems may read and modify data at the same time. Ideally, there would exist a solution where all systems may read data from any entities it wishes to, without having to worry about other systems modifying that same data at the same time, and without having the programmer care about properly ordering the execution and parallelization of these systems manually (which may sometimes not even be possible). In a basic implementation, this could be achieved by just putting all data reads and writes in critical sections (guarding them with mutexes). But this induces a large amount of runtime overhead and is probably not suitable for performance sensitive applications. Solution? In my thinking, a possible solution would be a system where reading updating and writing of data is separated, so that in one expensive phase, systems only read data and compute what they need to compute, somehow cache the results, and then write all the changed data back to the target entities in a separate writing pass. All systems would act on the data in the state that it was in at the beginning of the frame, and then before the end of the frame, when all systems have finished updating, a serialized writing pass happens where the cached results from all the different systems are iterated through and written back to the target entities. This is based on the (maybe wrong?) idea that the easy parallelization win could be big enough to outdo the cost (both in terms of runtime performance as well a code overhead) of the result caching and the writing pass. The Question How might such a system be implemented to achieve optimal performance? What are the implementation details of such a system and what are the prerequisites for an Entity Component system that wants to use this solution?
47
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?
47
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?
47
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.
47
How do we coordinate which order the systems get processed within an ECS? If I knew all of the systems at compile time, I could order them myself. However, I intend on having user defined mods. This adds a level of complexity, in that I (as the framework developer) don't know which mods will be developed, or installed on a particular user's machine. I've thought about adding some sort of execution ordering within core code systemRegistrar.register(PhysicsSystem.class).before(RenderingSystem.class) within third party mod systemRegistrar.register(ModSystem.class).before(PhysicsSystem.class) I've thought about an incidental ordering using some sort of message or event bus within core code PhysicsSystem public void update() do physics y stuff eventBus.send(new PhysicsSystemUpdatedEvent()) RenderingSystem public void handle(PhysicsSystemUpdatedEvent event) do rendering stuff eventBus.send(new RenderingSystemUpdatedEvent()) But this blurs the line between what will happen, and what could happen. Another thought that came into my mind is that we can be a little bit dirty and not care too terribly much about what order the systems get executed in, because even if we render before the physics are applied, the next frame will then render the physics update that was made in the previous frame. It's consistent, but it blurs the line between what happens within a frame.
47
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?
47
Entity System and "composite" entities I'm new to the Entity Component System pattern and there's something I cannot figure out. Let's say I have the following entity Player Components Position x 0, y 0 , Health max 100, current 50 , Sprites ... When I render an entity that has a Health component I also would like to render a health bar above that entity. Do I treat the health bar as a new entity and attach it to the Player i.e., the Player becomes a composite of entities or it the Health bar should be part of the Health component, in which case how would it be rendered created? To illustrate what I'm trying to say Player ChildEntities Character Components Position x parent.x, y parent.y , Sprites parent... , HealthBar Components Position x parent.x, y parent.y , Health max parent.max, current parent.current , Components Position x 0, y 0 , Health max 100, current 50 Is there an idiomatic preferred way of doing this? Thanks.
47
Event Based Entity Componenty System So, I'm new to ECS. The concept is very interesting in contrast to traditional OOP and heavy inheritance. I'm working on a game right now that is open sourced, but does not actually have a game loop. It works by sending and receiving packets, and acting upon those received packets. In that case, what would I be looking at in this relationship between Systems and Components? Let's say I have an incoming Movement packet that is telling me to move Player A 5 units to the right. And let's say I have a lot of different types of packet types (let's say up to 100), each for different stuff, like maybe making a purchase at an NPC store. Another one for purchasing at a player store. Or maybe inviting and expelling players from a party. Or inviting and expelling players from a guild or alliance. At that point, I start getting a little confused. I can definitely see similarities in .. Adding Expelling people from a party, guild, alliance But each of those packets contain different information at their core. I'm tempted to write a component that Guilds, Alliances, and Parties can use (like AddRemoveMemberComponent), but the information coming in from the packet makes me hesitant. How would those components handle specifically? Maybe I'm just entangling myself in traditional inheritance, so it's hard for me to see the uniqueness of data. Would I have unique systems for explicitly handling Party, Guild, Alliance expulsions and invitations? And how would I dynamically know what to do with these different packets coming in (different packets for alliance, guild, party).
47
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?
47
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!
47
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?
47
How to share Lua script between instances? I'm doing an agent based framework with C and Lua. I want to use Lua to code the Agent behaviour having an AgentClass class that have the name and source code and an AgentInstance class that have the lua State. I want to have a few AgentClass instances during execution but hundreds or thousands of AgentInstance objects. Is there any way to share the same lua script with different lua State? Or Is there a better way to get hundreds of agents without too much performance penalty? Options? Having compiled Lua code in AgentClass. Having lua State only on AgentClass, setting a self variable in every AgentInstance update. Other.
47
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.
47
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?
47
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?
47
User friendly scripting when using an ECS? I am currently creating a small hobby project to get back into game development, and I have decided to structure my entities using an ECS (Entity Component System). This implementation of an ECS is structured like so Entity In my case it's a unique int identifier that is used as a key to a list of components. Component Holds only data, e.g. the Position component holds an x and y coordinate, and the Movement component holds a speed and direction variable. System Handles components, e.g. it takes the Position and Movement components and adds the speed and direction to the position's x and y coordinates. This works fine, but now I wish to implement scripting into my games, in the form of a scripting language. In previous projects I've used an OOP implementation of game objects, which meant that scripting was pretty straight forwards. For example, a simple script could look something like this function start() local future entity moveTo(pos1) wait(future) local response entity showDialog(dialog1) if wait(response) 1 then local itemStack entity getInventory() removeItemByName("apple", 1) world getPlayer() getInventory() addItemStack(itemStack) else entity setBehavior(world getPlayer(), BEHAVIOR HOSTILE) end end However, when using an ECS, the entity itself does not have any functions like moveTo or getInventory, instead the above script written in ECS style would look something like this function start() local movement world getComponent(MOVEMENT, entity) movement moveTo(pos1) local position world getComponent(POSITION, entity) local future Future untilEquals(position.pos, pos1) wait(future) local dialogComp world getComponent(DIALOG, entity) local response dialogComp showDialog(dialog1) if wait(response) 1 then local entityInventory world getComponent(INVENTORY, entity) local playerInventory world getComponent(INVENTORY, world getPlayer()) local itemStack entityInventory removeItemByName("apple", 1) playerInventory addItemStack(itemStack) else local entityBehavior world getComponent(BEHAVIOR, entity) local playerBehavior world getComponent(BEHAVIOR, world getPlayer()) entityBehavior set(playerBehavior, BEHAVIOR HOSTILE) end end This is a lot more verbose compared to the OOP version, which is not desirable when the scripting is aimed towards mostly non programmers (players of the game). One solution would be to have some sort of wrapper object that encapsulates an Entity and supplies functions such as moveTo directly, and handles the rest internally, although such a solution seems sub optimal since it takes a lot of work to cover all the components, and every time a new component is added you would need to change the wrapper object with new functions. To all game developers that has implemented scripting in an ECS before how did you do it? The main focus here is usability for the end user, with as little "maintenance" cost as possible (preferably you don't need to change it every time you add a component).
48
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.
48
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.
48
How to make low poly ground look better I'm working in Unity and have created some low poly meshes using blender. Currently, the meshes look good, but the ground seems very lacking. I am not sure how to make it feel natural or even look good in general. Here is a current image The ground needs to remain mostly flat due to the game placing flat objects on the top of the plane and the image shows the exact camera angle we are using. But, as you can see in the image, the ground is extremely lacking and it doesn't look like a ground but instead just a flat background color. I've tried textures but it does not look good with the trees and low poly design. How can I make the ground look better?
48
Load destructible mesh at runtime Using the tutorial Components and Collision as a guide, to dynamically load a SphereShape the following is done AClass AClass() Create USphereComponent USphereComponent sphere NULL sphere CreateDefaultSubobject lt USphereComponent gt (TEXT("Root")) sphere gt InitSphereRadius(1.0f) sphere gt SetCollisionProfileName(TEXT("PhysicsActor")) sphere gt SetSimulatePhysics(true) sphere gt WakeRigidBody() Create UStaticMeshComponent UStaticMeshComponent mesh NULL mesh CreateDefaultSubobject lt UStaticMeshComponent gt (TEXT("Mesh")) mesh gt SetupAttachment(RootComponent) Load asset from filesystem define ASSET TEXT(" Game MobileStarterContent Shapes Shape Sphere.Shape Sphere") static ConstructorHelpers FObjectFinder lt UStaticMesh gt asset(ASSET) undef ASSET if (asset.Succeeded()) mesh gt SetStaticMesh(asset.Object) RootComponent sphere Now, when I try the same set of steps, but this time for an Actor that has a UDestructibleComponent instead of a USphereComponent AClass AClass() Create our UDestructibleComponent UDestructibleComponent destructible NULL destructible CreateDefaultSubobject lt UDestructibleComponent gt (TEXT("Root")) destructible gt SetCollisionEnabled(ECollisionEnabled PhysicsOnly) destructible gt SetSimulatePhysics(true) destructible gt SetEnableGravity(false) destructible gt WakeRigidBody(NAME None) Load asset from filesystem define ASSET TEXT(" Game MobileStarterContent Shapes Shape Cube DM") static ConstructorHelpers FObjectFinder lt UDestructibleMesh gt asset(ASSET) undef ASSET if (asset.Succeeded()) UE LOG(LogTemp, Warning, TEXT("It worked!")) RootComponent destructible I receive the following errors ConstructorHelpers.h 105 20 error cannot initialize a parameter of type 'UObject ' with an lvalue of type 'UDestructibleMesh ' ValidateObject( Object, PathName, ObjectToFind ) ConstructorHelpers.h 29 19 error incomplete type 'UDestructibleMesh' named in nested name specifier UClass Class T StaticClass() I've also tried adding .Shape Cube DM to the end of the string, similar to how the first asset was imported, but no luck. What is the correct way to load a DestructibleMesh from the filesystem and apply it to the UDestructibleComponent?
48
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?
48
How do I implement real time mesh deformation, with regards to environmental damage? I would like to be able to add the following feature to my tech demo at the moment bullets hit the walls, little pieces fly out of them, as well as decals appearing on the walls. Computing power is good enough, now, so that many games have destructible environments. I would like bullets to shatter small surface segments off the wall, ideally the segments that fly off would directly relate to the hole that is left, though I don't even know if this is how it's done in commercial games. How is this done? Are there simply a number of different meshes that are swapped out as, and when, objects are hit? I assumed that this would not be an accurate enough solution. Is real time mesh deformation feasible. and if so, how is it done?
48
Swapping limbs between meshes I'm trying to achieve what was done in the game impossible creatures. I will have a skeleton to which I will apply different meshes to i.e. torso mesh, leg mesh, etc. I would also like these meshes to be skinned together at the joints so that it looks like an animal and not like a robot. Any ideas as to how I go about achieving this?
48
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!
48
Angle between two planes I have two triangles in 3d space which share 1 edge and I would like to determine if the angle between their normal vectors is "uphill" or "downhill". In other words, if you set one flat, would the angle between them be acute (uphill) or obtuse (downhill). Hopefully that makes sense. So far I have the normal vectors of each triangle and have calculated the angle between the two triangles, however this angle is always 90 degrees. Vector3 v1 triangle1.Normal Vector3 v2 triangle2.Normal float cosAngle Vector3.Dot(v1, v2) (v1.magnitude v2.magnitude) float degAngle Mathf.Acos(cosAngle) Mathf.Rad2Deg Is there a trick I am missing that lets me determine which direction this angle is in?
48
How to fix a crowbar mesh deformation problem I am having a problem exporting my model to Garry's Mod. Every time i compile the model in crowbar it comes out deformed like this when the model is really suppose to look like this how do I fix this is there something wrong with the collision? I am also ready to provide whatever files information are needed to solve this problem. I should also mention that the mesh has multiple objects from each sphere that are joined but not connected. I went to the arqade for this at first but they said it was offtopic and that I should come here instead.
49
Market as a single game or as a studio? I'm creating an RPG with a theme of a hero that must restore peace to a world fallen to evil forces. It serves as an educational tool. I'm creating a promotional website for it and using other online social tools for marketing. I only have one focus to make this game as great as possible for people to learn. I've seen some companies that market themselves as their product name, like DuoLingo, and some that market as the studio, such as Strawberry Games. I don't have a game studio and have simply been marketing (FB page, website URL, etc) as the game's name, Lexicana's Destiny. Does it really matter which way I market it? If so, why?
49
Novice Mobile Game Developers Publishing on our own or Publisher? So we are almost done with our first indie game, developed on Android. We believe that the game has potential, our graphics guy is damn good so we have some good eye candy in our game. Now we are thinking what should be our starting step? We can purchase the Google Play account and launch it on our own, but we aren't sure if we'd be able to advertise it well and get something big out of it. Or we can contact a publisher, and talk about some deal. Which one is better? What are the pros and cons of both, considering this is only our first game and we intend to make a lot more. Also considering that we're only students yet, currently in our senior year. We would love to generate some revenue out of it. What are the best ways of contacting publishers? How do we approach them and deal with them? Many thanks for your kind help!
49
How do you market assets that are niche but that those people definitely want? I just got done canvasing surveying developers, and it is clear that there is a market for a few niche categories of audio assets that I suspected would be useful to them. While the overall category of assets is commonly desired, it can only be broken down into separate categories, which individually are completely niche due to the wide variety of games nowadays. How can a niche but useful asset be effectively marketed to (mostly indie) game developers? It is known that there are people out there who want it, but the likelihood of a completely random individual wanting it is low. So if the asset was created, and there was low competition among asset producers for it, how could one ensure at least some of those people find it (without actually cold calling them)? I would explain in more detail, but I don't want to come off as though I'm trying to advertise anything here.
49
Allowing a secondary market for online content Many games with an online component, allow players to buy various kinds of content. As far as I know, none of them allow a secondary market where players resell purchased content to other players. Presumably this is because the developers think disallowing the secondary market will get them more sales. However, there seems to be a widely held school of thought regarding Magic the Gathering (the nonelectronic card game) that the existence of a secondary market actually increases revenue by encouraging people to buy more cards in the hope of being able to resell them. Whether that theory is true or false, the mere fact that many people believe it, should encourage at least some video game developers to try allowing a secondary market. Given the existence of a reasonably widely held theory that this is a good idea, why is it that no video game developers whatsoever allow a secondary market?
49
Best free advertising for Facebook strategy game I have written a game for Facebook. I think the game is fun to play, although the graphic presentation is primitive since I am not a graphic artist web designer I am the only Facebook user playing the game at this time. It does not appear to appeal to FB's demographic audience who seem to prefer less complex and less challenging games. Does anyone have any ideas on how I could get the word out about my game to the proper audience while spending very little or no money?
49
Do I have to ask for permission to use real company logos for advertising props in the world in my sports game? I'm making a simple turn based Android ball flicking soccer game and I was thinking of creating a theme in a sports game, like soccer for example, usually had advertisement banner on walls and a bit realistic but cartoony. It is usually encountered in most sports based game in any gaming platform. I have a question regarding this topic. Is it required to ask a permission to used some recognized ad banner designed walls (e.g. Adidas, Samsung, McDonalds, etc.) to be used as props for the game field like this one for example?
49
Is a game's world wide visibility in app stores affected by the publisher's country of residence? I've noticed on Apple Store (and I assume on Google Playstore too) I find different games and apps in France than in the US. Does this mean if my company resides in a small country and I register my game in this country, it'll only be shown to users of my country? Or is it just a matter of some settings and I can decide to be shown all around the world, for instance for American users (which is a larger market than my country), same as game producers living there? Does a game developer's country of residence influence how many downloads world wide he can reach at all? My question is about Apple Store and Google Playstore, but answers for other platforms are welcome too.
49
Why don't top selling mobile games have localization? For example Plants vs Zombies 2, Angry Birds, Bad Piggies, Candy Crush Saga, Temple Run 2 and so on. These games are available in English only. These companies have huge resources why don't they localize their games?
49
Where to find passive advertisements? Imagine a soccer game. While the player is playing a match, he is seeing the billboards all the time. I want to include that kind of advertisements in my game (obviouly, making profit). Just a brand logo, not a banner the user has to click. Does this even exist? Is there any AdMob like which allows this kind of advertisement?
49
How can I promote my game? I am a beginning indie developer, and I want to get the word out about my game. What sites can I go to to ask about reviews of my game, and where might I be able to talk about and get feedback on my game from players?
49
Where to promote your indie game? Possible Duplicate Where to advertise my game? Let's say I have developed a game and I want to "get it out there". What I have in mind is open source, non commercial games. What websites do you know of where you can promote your newly developed game, rather than simply posting it on your blog?
49
Where to find market research info on adventure games? Looks like adventure games are on the rise again. There were several great releases in 2012, including brilliant and highly acclaimed Walking Dead from TellTale. Is there a market research that proves the new rise of adventure games? Bonus points for revenue estimates and such. I'm particularly interested in mobile games segment, but everything else is of interest as well.
49
Whats the best way to publish and promote an app by myself? My first little casual action android game is nearly finished. Its my first one and i dont expect any sucess. But nevertheless i want to try to publish and market it by myself. But what can i do without any bugdet? How do i attract and reach people ? Are there any tricks ? How did you published and promoted your first app game ? And what is your experience with self publishing marketing ?
49
How can I acquire marketing and sales data for games? I need to evaluate a marketing perspective for a videogame in order to predict its income, sold units, etc. Since this sounds like quite a bit of an impossible task, I thought I could collect some statistic for similar games in order to have an idea. Is there a way which I could figure out selling statistics about games on specific platform? For example collect statistic for game xyz available on Steam platform or game abc available on HumbleBundle. I think that could be a good practice to achieve this goal. EDIT recently was published SteamSpy, which offers a lot of statistics about games on Steam platform.
49
Marketing a game with limited budget I am building a decent multiplayer iOS Android card based game. While this game is played with regular old 52 cards deck, it does have unique rules and game play. That makes it little hard to market since no one is precisely looking to play initially. I have been researching quite a bit about game marketing and most recommendations are to build out fan following which is also quite hard and time consuming (taking away from building game). I have some indie marketing budget ( 5k) I set aside to help gain some traction. While I understand that this not my strengths, what are the best ways to invest it into the game?
49
Where to promote your indie game? Possible Duplicate Where to advertise my game? Let's say I have developed a game and I want to "get it out there". What I have in mind is open source, non commercial games. What websites do you know of where you can promote your newly developed game, rather than simply posting it on your blog?