• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By ThunderTwonk
      Hello everyone, I am working on a game idea and since I am still in the process of learning C# and the features available in unity I was hoping some of you might be able to offer me a little insight on things in general for getting started.
      I guess the basic components of what I'm wanting to create would be a Multi-levels management/city builder/rpg.
      The goal is to provide a framework for players to interact with, build in and affect the world both from a 3rd person action RPG as well as a zoomed out 4x style view (This would be something unlocked through gameplay)
       
      As for my questions go I was wondering if anyone had resources that could help me learn.  I've been on youtube as well as enrolled in an online course for basic unity and C# and will continue those but if anyone has any words of advice, a place that has good information and tutorials etc.
       
      Thanks for your time.
    • By Cahit Karahan

       
      Hi, I'm new in this forum. It is honorable to see such communities exist. I would like to share my new game. I did for android with unity. I know the game is a little awkward , but you have to know that this game is from the time when Unity's name is Unity3D  I have made my first game when I was 12. Now I am 22.  I have taken a lot of experience in this process and I can make better games nowadays. I have published this game nowadays but actually this game is very old but also it is very special for me :))
      I have just wanted to retouch and share this game, because it has a very important place for me.
       
      DESCRIPTION FROM GOOGLE PLAY STORE

      It's a special free 3D horror adventure action game for the halloween. Fun with scary sound effects and musics, 3D realistic graphics, you will feel the horror in the deep of your heart. Use your reflex. Totally free adventure. Totally scary horror game. 

      Tamarra, she is a beast from our world. She needs to consume souls from innocent people to stay alive. Story begins, the old Elaris tribe had lost their everything because of this beast who lived in the well. Araknas was the most powerful warrior of the tribe. One day, Araknas's mother was killed by the servant beasts of Tamarra. That's how Araknas's journey to the well begins. Tamara's well is guarded by horrible beasts. Araknas has to pass all servant beasts until he reaches Tamarra.

      Even death at the end is worth the revenge. 
      Are you brave enough to jump into Tamarra's well?

      Survive from witch attacks, clown attacks and many scary creature.

      - Realistic 3D graphics.
      - Scary sounds.
      - Scary musics.
      - Best experience with headphones.
      - A demon cage where you can imprison all the demons one by one
      - The witches do not like help, but they love blood stone. Witch store where you can develop your abilities and get new abilities.
      - Countless beasts.
      - At the end of the well there is a hidden surprise for you.

      *We do not recommend this game to people with clown phobia, spider phobia, or panic attacks.*

      **!!!**Note : This game is an early-access game, we are upgrading new features every day, new beasts, new improvements, as an example online 1vs1 fall on the list, so stay on connect and follow Halloween : Horror Well on Google Play.**!!!**

    • By INFRA
      SCAN. DRILL. SURVIVE.   ISOLATED Release in May 1st 2018   https://store.steampowered.com/app/805950/Isolated/   A game by Jérémie Bertrand Music & Sound Design by Pierrick Querolle *** Our solar system has been invaded by strangers. For the purpose of a possible negotiation, a team of astronauts is sent to the moon. Alas, they are shot before even arriving on the scene. Only one astronaut survives the crash and his only goal will be to go home...   GAMEPLAY   Shoot enemy ships to avoid being invaded. Be precise in your movements, because it's better to lose a bit of life at the top than to lose it all at the bottom. Take out your drill to destroy the stones in your path. Validate your identity to cross the different laboratories. Reach the flag before losing your three lives.   And all that... at the same time! Will you be able to go home? If the answer is yes, how long will it take?
    • By BigJiggly
      Hello! So, I've been the leader of BJP for a while now. I'm a bit bored of taking the role I always take, leader. I was hoping someone out there is looking to forge a team maybe and needs a programmer. 
      I have experience mainly in the Unity engine(C# intermediate) and I have a very small amount of knowledge on Shaders, as well as experience on developing games(usually end up stuck in dev hell) and leading experience from my last team which at one point reached 11 people. I personally love the Unity engine and prefer to use it as it's the development environment I'm comfortable with. 
      I have used Unity for over a year and a few months, I'd consider myself an intermediate at the Engine, but to this day Unity still surprises me. 
      I live in the United Kingdom, I find it a bit strange to work with other programmers as the ones I've worked with tend to leave their code heavily unoptimised and I'm a on the go optimise kind of guy, I also like to get things done quickly.
       
      If you're a new team and need a programmer that has high levels of ambition and strives to maintain the motivation throughout the team, then I'm your guy. I don't care if you're just beginning because I'm all for helping people learn!
       
      To finish this off: I like to get things done and I like to get them done right the first time, if I fail I will do it again and again, etc, until I loose all motivation. So if you're a modeller or an artist, please don't leave me to do all the modelling/art as well as the programming and sound. I do have experience in all those areas but my main power is in programming and I'd prefer to keep it that way.
       
      [If this was posted in the wrong forum, sorry, I don't really know the layout of this website yet]
    • By Alexia
      Hi all,
      A small team are currently undertaking a fairly large game project involving multi-playing, taming and other complex game mechanisms.
      We are looking for someone who is experienced in programming a wide range of mechanisms, more information is on our discord server. It is also a learning experience and we wouldn't expect you to know how to do everything we wanted, but just ask that you would be willing to learn how to.
      If you are interested in joining the (rather long term project) just message me and i'll add you on discord.
      Thanks for your time,
      Alexia 
  • Advertisement
  • Advertisement
Sign in to follow this  

Unity Component based architecture .... for game!

This topic is 679 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there any link to for Component based architecture in some complex case / real case  that objects has a lot of relation to each other?

 

I have faced some difficulty when tried create some relation Ex. Bullet-Component rotating around Rocket-Component.

 

It is hard to find good links, here is what I have :-

None of these links show how to manage relation.

 

The order of execution of system (that manage each type of Component) seems to important too (Ex. Physic must before Graphics),

but none of these links describe it.

 

I am noob, help!

 

Edit

The problem is mainly "Where should I store the relation?   Bullet or Rocket?  Something above them?"  

 

If I create some component/system that depends on two (e.g. BulletRocketSystem) , I will have to aware the order of execution.

BulletRocketSystem should execute after Bullet and Rocket's system.  

If Bullet will be deleted by Bullet_System's command, the BulletRocketSystem must be notified and remove reference of it.

 

This promotes couple between System, which is bad.

Moreover, there have to be a headquarter to enforce the order, I don't know if there is non-ugly way to do it.

 

---

 

Thank for a lot of responses, I have learned a lot. +1 all

 

@Alberth:  Thank!   I forgot to think about it carefully.   I should not force myself to use entity system to solve everything.

 

@Norman Barrows:  You are right.  Unity does it, so I followed it.   I do it for business (hopefully).

 

@phil_t:  I have edited OP.  XD

 

@Tangletail:   You caught me.  Rocket should = Shootable + HP + Physics + Graphics + ....   I hope this is what you mean.

Edited by hyyou

Share this post


Link to post
Share on other sites
Advertisement

Any particular reason why you don't drop component-based design? Or just use it at the parts where it fits?

 

I have no experience with these architectures, but at times it looks like a religion to me. People try to push every single thing into the system, for seemingly no other reason than it being the system.

In my experience, trying to unify everything in one system doesn't give nice results.

Share this post


Link to post
Share on other sites

>> I have faced some difficulty when tried create some relation Ex. Bullet-Component rotating around Rocket-Component.

 

precisely, what are you trying to do?

 

 

>>  Component based architecture

 

ECS (as opposed to somewhat more straightforward composition) has a number of uses:

 

1. team members without the access and/or knowledge to modify the code base must be able to define new entity types from pre-defined components already existing in the game engine. test question: do team members who must define entity types not have code access and / or knowledge?

 

2. to reduce build times by making entity type definitions data driven, so you don't have to recompile when you define a new entity. test question: how often do you define a new entity type?

 

3. there's a method for optimizing update once you can squeeze no more clock cycles out of render and you're still too slow. the result is more or less an ECS. test question: have you already optimized render, and you're still too slow?

 

4. just for fun or as a learning exerience. test question: are you doing this just for fun, or just as a learning experience?

 

if you pass any of these test questions, ECS may be called for.

 

note that generic game engines like Unity et al have requirement #1. I suppose that's why some folks thinks an ECS is "de rigueur".

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

 

 

I have faced some difficulty when tried create some relation Ex. Bullet-Component rotating around Rocket-Component.

 

 

 

 

As a general rule, if you don't want A to depend on B, or B to depend on A, then you can create... C... which depends on both and manages the needed interaction between them.

 

I don't think your problem has anything *specifically* to do with component-based design. You would need to address it in other architectures too - it's just that a component-based design forces you to think about limiting dependencies more, so it the issue becomes more obvious and less trivial to hack your way around.

 

I don't really know why a bullet would need to rotate around a rocket - but can you just add a script to the object that knows about "bullet" and "rocket", and manages the needed synchronization between the two?

Share this post


Link to post
Share on other sites
Why do you have bullet and rocket explicitly defined as components?

You might be horribly misunderstanding the idea of ECS.

The idea is to make each component as data. Bullet and Rocket are nearly identical to each other. The two are objects with similar components.

A bullet has velocity, a sprite, collision and damage.

A rocket has nearly the same, except you have a particle trail.

The explosion is just another object that has a short life with a trigger, particles,and damage.

You need to decide on how the games logic is handled, as systems are one of the major fallouts of the system. Edited by Tangletail

Share this post


Link to post
Share on other sites

At the end of the day.... its really really really not about the code - it's about what the code does. You can get crazy, obsessive even, about trying to organize code in a way that makes you sleep well at night.

 

I have had the best luck so far with just writing code to make things work and reworking when necessary. What I found is that the more experienced I get the better I get at writing systems that work well together that require minimal rewriting. But there really is no short cut to get there. I believe ECS (or in general composition) is the result of this process for many programmers who have then shared their findings with the world.

 

So you can either spend a bunch of time trying to exactly mimic what these other programmers have done, or you can go through the process yourself and try to take their most important lessons in consideration - focusing more on the functionality than the code itself.

Share this post


Link to post
Share on other sites

At the end of the day.... its really really really not about the code - it's about what the code does. You can get crazy, obsessive even, about trying to organize code in a way that makes you sleep well at night.

 

I have had the best luck so far with just writing code to make things work and reworking when necessary. What I found is that the more experienced I get the better I get at writing systems that work well together that require minimal rewriting. But there really is no short cut to get there. I believe ECS (or in general composition) is the result of this process for many programmers who have then shared their findings with the world.

 

So you can either spend a bunch of time trying to exactly mimic what these other programmers have done, or you can go through the process yourself and try to take their most important lessons in consideration - focusing more on the functionality than the code itself.

After years of coding, I realized when I read about ECS that it was what I eventually settled on.  It works, but I work with systems of components (a entity is just an ID, not even a struct/class, it's just an ID in a vector passed on to components as a parent ID more or less).

As for Norman Barrows, tons of engines use ECS, why there were GDC talks on the subject.  Unity uses components, never looked much more into it but they work great for data driven.  You seem very confused on their use.  Its not how often you create a new data type like Engine or Missile etc.  It's how often you combine these things into game objects like ships, or cars, and make new ones with tweaks etc.  Data driven code iterates insanely fast and that is what is most important.  Writing code that allows designers, artists and other non-coding team members rapid and easy access to testing new ideas.  If a programmer needs to be involved, you likely have a horrible system or its very early in the design phase where a lot of code is still being added.  ECS is no different in it's usefulness to a designer than a visual shader editor is to artists.  Take as much work away from programmers as possible is the best idea ever, we can then focus more on fixing bugs, adding needed features, cleaning up the code, etc.  Instead of writing thousands of lines that might get cut when that part of the game is found to be boring or pointless.  If it was all data, it just gets deleted and you're more or less done.

There is a time and place for ECS, it is not a magic bullet.  I do not have an OnUpdate() etc function for my entity, it's a lot more cache friendly to have each component saved in it's respective system.  Some systems have covered multiple components (position and movement for instance).  There is no right or wrong way to implement it honestly within reason.  At the same time I also do not completely shun inheritance, I just try and figure out other ways around it.  But it still exists in my code base and I do not lose sleep over it.  Also my graphics system is in no way really tied to the ECS system.  I use ECS more or less for purely game object code.  YMMV though.

To the OP, to me a bullet is not a component, but an entity made up of components like Target, Position, Velocity, TimeToLive, etc. and give/take what you want, was off the top of my head after midnight.  Then the rocket would be (also an entity) much the same with Fuel, Engine, etc. and the Target of the rocket could be the bullet (in my case purely an ID), which it would circle if it could never directly intercept, or based on the rocket AI component.  

Share this post


Link to post
Share on other sites

 

The problem is mainly "Where should I store the relation?   Bullet or Rocket?  Something above them?"  

 

If I create some component/system that depends on two (e.g. BulletRocketSystem) , I will have to aware the order of execution.

BulletRocketSystem should execute after Bullet and Rocket's system.  

If Bullet will be deleted by Bullet_System's command, the BulletRocketSystem must be notified and remove reference of it.

 

This promotes couple between System, which is bad.

Moreover, there have to be a headquarter to enforce the order, I don't know if there is non-ugly way to do it.

 

 

The order of execution of systems is not hard to enforce. In fact, it is essential that there be a strict order that you define. There's nothing ugly about it. This could be as simple as the order in which systems are added to your world, or perhaps each system has a UpdateOrder number for it, and the world keeps the systems sorted in this order when doing updates.

 

It's also not necessarily a bad thing if one system depends on another (for instance, you might have a System that organizes entities in some spatial partitioning scheme - other systems will need to query this).

 

But like others, I question your choice of Rocket and Bullet components - but it's hard to say without knowing more about your game and what they do. Rocket I can kind of understand (it could contain like amount of fuel, engine max speed, etc...). But what is unique about a Bullet? I guess it could contain information on the types of damage it deals, etc...  Can you explain what makes your Bullet and Rocket unique, and why you need specific code to deal with them (as opposed to just being entities with transform/physics/model components)?

 

"If Bullet will be deleted by Bullet_System's command, the BulletRocketSystem must be notified and remove reference of it."

 

Managing entity lifetime can be one of the trickier parts of an ECS. But it is something that should be solved generally. That is, when an entity is destroyed, you should have code that notifies any systems that were interested in it that it was removed. This is also true if you remove a component from an entity that causes a system to no longer be interested in that entity (i.e. removing Bullet component should tell the BulletSystem that this entity has been removed). Again, this should be done at a general level, by having systems express which components they require entities to have.

 

Ideally, if a system doesn't store any information about an entity, then it may not even care if it was destroyed. That is, if your Bullet system update logic can just say "enumerate all the entities with Bullet components" each time, then it really doesn't need to know if something was destroyed or added, since it will always get a current list of bullets.

 

One final point: you may want to consider delaying the destruction of entities until the end of the update cycle. Just mark them to be deleted, then have some code that actually removes them at the end or beginning of the update cycle.

Edited by phil_t

Share this post


Link to post
Share on other sites

If I create some component/system that depends on two (e.g. BulletRocketSystem) , I will have to aware the order of execution.

BulletRocketSystem should execute after Bullet and Rocket's system.  

If Bullet will be deleted by Bullet_System's command, the BulletRocketSystem must be notified and remove reference of it.

 

This promotes couple between System, which is bad.

Moreover, there have to be a headquarter to enforce the order, I don't know if there is non-ugly way to do it.

 

Order of systems is a very basic thing that will need to be set one way or the other. You can't have all systems running in whatever order. Doesn't makes sense to render if the transforms haven't been updated. Doesn't makes sense to run the sound system or the asset streaming system if no movement was processed yet.

 

In Artemis ECS, and consequently, the fork I've been working on (dustArtemis, look at my signature), all systems get notified when entities get added, removed or changed. So they have the opportunity to react to situations like yours, or if an entity mutates (ie, you remove/add an effect over an entity).

 

Order is enforced because you set it indirectly (by the order in which you added sub systems to the World instance) or directly (via a priority value). Here:

https://github.com/dustContributor/dustArtemis/blob/master/src/com/artemis/World.java#L306

 

Thats the main processing routine. First it notifies all systems of entity changes made during the last tick, then it notifies the entity and component managers of the same changes (so components can be removed/entities deleted) then it lets systems process their main workload, which might end up in more entity additions/removals. Rinse and repeat.

 

Moreover, the main focus of decoupling system ordering always seemed to be so you can run each system in their own thread. Over the years developers realized it isn't a good idea. Workloads of each subsystem vary a lot, so most of the time one thread would get chewed while the others would barely do anything. Nowadays the approach is to go "wide"  at each system. Got a couple thousand tasks to run in the movement system? Parallelize them in groups, then collect the results (if such step is needed) and move to the next system.

Edited by TheChubu

Share this post


Link to post
Share on other sites

>>  It's how often you combine these things into game objects like ships, or cars, and make new ones with tweaks etc.  

 

that's what i call defining a new "entity type". IE a new kind of "game object".   some games must do this often and have many people who must be able to do it with various skill sets, and some games do not. like most things it depends on the work to be done, and the size and skills of the team.

 

IE if you were going to bang out pong, pacman, galaga, space invaders, or missile command, etc. by yourself on weekend just for fun, you wouldn't bother with ECS.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement