Git Product home page Git Product logo

Comments (10)

sschmid avatar sschmid commented on April 28, 2024 2

Quote:

Designing levels

Let me explain, how I see this:
For me levels are just data - some configuration where things are and what their state is. E.g. a building at a certain position in the world that can be attacked and has a certain health.
I don't really care if I get this information from a json or a scene from Unity. In both cases I parse the source and create entities based on the data. In this example I'd create an Entity with BuildingComponent, PositionComponent, AttackableComponent, HealthComponent
The cool thing is, when you're designing your level in Unity, you already have the view, too! So when you parse your scene you already can link the actual building GameObject to the Entity by adding a ViewComponent

public class ViewComponent : IComponent {
    public GameObject gameObject;
}

Again: a designer is completely free to create a level. He/she can setup e.g. multiple buildings at different positions, with different health and so on... the important part is: All the Monobehaviours on that GameObject should NOT have any game related logic! Only configuration like transform, health, attackable, etc. They might have some View related logic like animating something on the building. The GameObject should be treated as a dumb view with no behaviour! It's just a View

from entitas.

laurentopia avatar laurentopia commented on April 28, 2024 1

Here is an example which I think combines the best of both ECS and Unity world.
From the race car example add this to cars you drop into the scene:
using UnityEngine; public class OpponentInScene : MonoBehaviour { public float speed; }

Then change the InitOpponentSystem to this:
`using Entitas;
using UnityEngine;

public sealed class InitOpponentsSystem : IInitializeSystem {

readonly GameContext _context;

public InitOpponentsSystem(Contexts contexts) {
    _context = contexts.game;
}

public void Initialize() {
	// scan scene and register opponents which already exist
	var ops = GameObject.FindObjectsOfType<OpponentInScene>();
	foreach (var o in ops) {
		var e = _context.CreateEntity();

// e.AddAsset(resourceName);
e.AddView(o.gameObject);
e.AddPosition(o.transform.position.x, o.transform.position.y, o.transform.position.z);
e.AddMove(o.speed, o.speed);
}
//generate
const string resourceName = "Opponent";
for(int i = 1; i < 10; i++) {
var speed = Random.value * 0.02f;
var e = _context.CreateEntity();
e.AddAsset(resourceName);
e.AddPosition(i + i, 0, 0);
e.AddMove(speed, speed);
}
}
}
`

(sorry github ate my formatting, I'll figure it out eventually)

from entitas.

sschmid avatar sschmid commented on April 28, 2024

I invite you to visit the Entitas chat, where we just had discussions about this very topic:
https://gitter.im/sschmid/Entitas-CSharp
Alternatively click the "Join the chat" button in the readme

from entitas.

sschmid avatar sschmid commented on April 28, 2024

You might want to scroll up until you see my reply saying "Designing levels"

from entitas.

sschmid avatar sschmid commented on April 28, 2024

I might create a third example project soon to illustrate what I just wrote, since this is a question that already came up a few times.

from entitas.

TheLouisHong avatar TheLouisHong commented on April 28, 2024

That would be amazing 😄 Thanks again! Really enjoyed the talk! Did a fantastic job selling what you guys have to offer to the audience. Instantly fell in love.

from entitas.

SvDvorak avatar SvDvorak commented on April 28, 2024

I'm one of the persons who had the same question as you. I've made something that works for me currently which essentially scans through the scene at start for any gameobject with a Component container-MonoBehaviour and creates entities using the components specified in the container. The container only has a list of IComponents that I can add and edit using VFW (https://github.com/vexe/VFW). This does not work during runtime though, then I have to go to the entity pool and edit those components, I'm still thinking about how to solve that (or just make it easy to jump to the correct entity during runtime). I'm also curious to see @sschmid solution =)

from entitas.

sschmid avatar sschmid commented on April 28, 2024

@mzaks wrote a blog post addressing this question:
Games, Data and Entitas

from entitas.

goshki avatar goshki commented on April 28, 2024

I think there's a project that tries to solve this very problem: https://github.com/WoLfulus/Entitas-CSharp-VisualEditor

from entitas.

WoLfulus avatar WoLfulus commented on April 28, 2024

@goshki Haven't had time to update it to the last version of entitas though.

from entitas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.