• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Panicbox

Complex Components in Entity Systems

6 posts in this topic

Alright, if you haven't heard of Entity Systems before, here are a few links that got me started:

[url="http://t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/"]http://t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/[/url] - A really helpful series on Entity Systems

[url="http://entity-systems.wikidot.com/"]http://entity-systems.wikidot.com/[/url] - The ES wiki

[url="http://gamadu.com/artemis/"]http://gamadu.com/artemis/[/url] - An ES framework similar to the one I'm using now.

So if you [i]have[/i] heard of them, my question is this:

How do you get complex behaviour out of an Entity using Systems and its Components alone? An example: say your Entity is a spaceship for all intents and purposes. Each spaceship might have a different weapon, and so fire bullets in a completely different way. How can you give it a data-only component that describes exactly how it fires bullets?

Or think of its AI (in the game dev sense), how can you describe how it moves and [i]when[/i] it fires based solely on its components?

I'm not sure if there is a clean way to do it, but at the moment it's causing me significant trouble. I have like three git branches doing it different ways and I hate them all.
0

Share this post


Link to post
Share on other sites
It might be a good idea to tell us exactly what trouble you are having because, to me, from your description these are not complex components.

Honestly without much description of what type of projectiles you are having it is hard to describe a component and system that will match all your use cases will you be using simple raycast tests or physics simulated projectiles? Will there be ray guns? Or what? I don't know the limits of your technology or how it works.

A projectile for my game would be it's own entity which I would create from physics components and a projectile component. The projectile component would have stuff like initial velocity and who shot it and would notify it's creator when it hit something (probably with what it hit). So a 'firing component' would just be an entity link to create.

I always do AI in scripts which will access systems like path-finding and receive messages from the physics system when a collision occurs. So my script would just create the entity I wanted when it shot (after deciding to or receiving input (well after an animation maybe [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img]). Edited by CRYP7IK
0

Share this post


Link to post
Share on other sites
The bullet example I think could be addressed using components (depending on how "differently" you want bullets to fire).

For more complex things, I attach scripts to the entity (via a Scripts component).They don't really keep the potential performance benefits of a component system (e.g. operating on all instances of particular data at once), but they also tend not to be as performance-critical anyway.
0

Share this post


Link to post
Share on other sites
There are a number of ways to implement a component based entity system. The system I have been working on works a bit like this:
[list]
[*]Components provide the data/properties/attributes and can provide behavior.
[*]Components register their properties with the parent entity so other components can access common data (eg. physics/render both need access to transform data).
[*]Sub-systems manage and update the components.
[/list]

For the majority of things you will already have a bunch of sub-systems that are part of the core engine (physics, rendering, animation, etc) and so a lot of your components plug into these systems nicely.

For your spaceship/bullet example you could try tackle the problem in a more generic way. What makes up a bullet? In the most basic sense it has some kind of visual representation along with some physical properties. You could therefore create a bullet entity that is made from a couple of components:
[list]
[*]TransformComponent
[*]PhysicsCapsuleComponent
[*]SpriteComponent or ModelComponent
[/list]
For the above, the [i]TransformComponent[/i] is there to provide the world/local transform that the physics/render systems can read/write too. The [i]PhysicsCapsuleComponent[/i] is managed by the physics sub-system and it's attributes define the physical properties (velocity, acceleration, friction, collision mesh, etc) which the physics sub-system uses to simulate the object. The [i]SpriteComponent[/i] or [i]ModelComponent[/i] provides the visual representation and it is managed by the rendering sub-system.

The rendering components can be broken down even further but I find in most cases your components will generally map to an existing higher level sub-system, you just need to think in general terms of what actually makes up the object you're trying to create. Edited by Shael
0

Share this post


Link to post
Share on other sites
The Script components make a lot of sense and are a great idea.

Sorry I wasn't more clear about the projectiles: if it were only a single projectile there would be no problem, but it's a pattern of shots that I want to achieve. For example, spirals or rings of bullets being fired at once. So it's not not so much describing the projectile as describing how many, and in what formation, they are fired.

Is this something I should be using scripts for as well?
0

Share this post


Link to post
Share on other sites
There is nothing wrong with the components of an entity having some behavior of their own, don't make complex logic and math computations on script, they tend to get expensive since they have to be interpreted, the best us of scripts is to connect different behaviors in a dynamic way. Don't overuse scripts.
Shooting is always going to be shooting, that is a behavior that you should implement in your code, deciding to shoot is something more dynamic that you may want to do through scripts.

As for the shooting pattern, its a matter of data, you can write as data a representation of the pattern, frequency, directions, speeds, projectile type. All this is data, not behavior, your behavior is shooting, which will receive this data and simply execute it, keeping track of time between shots and so on.
0

Share this post


Link to post
Share on other sites
I would look at it this way. Your ship might have a Weaponry component, which holds the current weapons they can shoot (and possibly which one is active, if you can switch between them), as well as if its time to fire (set by AI System, or player's input system). In your Weapon system, it would create an entity based on the current firing weapon name. The entity could be built from loading an xml file (for that weapon's name) that describes the weapon's bullet's components (image, velocity, damage, number of pellets (if it spreads) etc.). If it's a special bullet, the Weapons system should know how to handle it

Just a thought.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0