#Building Placement System Using DOTS

1 messages · Page 1 of 1 (latest)

serene pumice
#

Hello,
I have been trying to create a building placement system using dots ,for my RTS game that I am working on, and I am having a difficult time trying to figure out what and how to do it.
Anyway I was wondering if anyone could help me out with this since I am feeling a bit lost and I am not sure how to handle the building placement system.

edgy sierra
#

DOTS would not change how placements would work anyhow, so any existing approach will do. The only thing that will differ is how you store the data about placement, building shapes and etc

serene pumice
#

Should I store the data inside the subscene as well ?

edgy sierra
#

It's more about how component layout is going to be

west palm
#

@serene pumice you question is about what ? how to instantiate your buildings with dots ? or how to structure the system so you can do it easily ?

serene pumice
#

I want to know how to handle a building system ( pressing a hutton to spawn a building based on mouse position) that uses dots.

#

How to instenciatd a building using dots based on mouse position

serene pumice
#

What I think I will do is when user clicks on the button it will show the "clone" of the building which will be a normal prefab and will change it's position using Update to get the position based on mouse position.
When the user first click a building button to place the building a bool value will change from false to true therefor letting the user pick a spot for the building.( will change back to false when the user will either cancel placement for the building or when he places the building )
Then when the user wants to place the building he will click the mouse. When he clicks the mouse 2 thing will happen:

  1. The game object of the clone will change to an entity with the 3D model of the clone
  2. The entity will be added a position component that will have position value of the clone

Is this the correct approach for handling the building system ?

edgy sierra
#

YOu don't need game objects at all here

#

with dots ECS you are supposed to just work with entities

#

mixing two is generally a pain

serene pumice
#

So I should use an entity prefab component in order to get a reference for the building that I will use in order to instantiate a prefab of the building at the position of the mouse

#

Should the UI that I use in order to spawn the buildings be an entity?

#

or can I use a bool that will change whenever I press a button ?

edgy sierra
#

you are mixing UI and logic

#

all I'm saying, is game object is totally extra step

#

if you are building your game with ecs

#

you shouldn't care for them really

serene pumice
#

Is it ok to mix UI with ECS?

edgy sierra
#

generally it's not ok to mix UI with anything

#

as soon as you mix your UI code with logic code

#

things get ugly

#

I legit remember a game where UI manager was root of any logic in game notlikethis

serene pumice
#

Unfourtently I must use UI for this part

#

How can I mix them though

edgy sierra
#

that's it

serene pumice
#

I don't know how to spawn an entity afterwards

#

How do I get a refrence to the entity on start or as a game object and than change it to an entity

tiny gorge
#
  1. If you want to differentiate your buildings for any specific case, you can devise an ID system of your own. Each entity carries an ID component contains enough data to identify it.
#
  1. You should separate your game logic with your UI logic as much as possible. UI interactions only produce data that will be fed into your game logic systems.

For example, a user can choose a building from list view then a preview of that building appears on screen. The user can move it around, rotate it before placing it onto the map (actually build it).

You should think this as just a "presentation" step where user is interacting with only 1 object (the building preview). It's OK to be a UI thing.

However, the moment the user decides to build it (for example, after the user clicks their left mouse button), that action must produce some data, and that data must be fed into a game logic system. This system handles that data, transforms it into the entity and its components that represent that building: this is the actual spawning.

Let says your structure have to pass 5 stages to be a complete and functional building. And each stage presents itself by a different 3D model. You should think of these stages as pure data, numerical values only. There will be a system to query these numerical values and transform them into another form of data to display correct 3D models on screen. The act of displaying 3D models is also a part of the "presentation".

Effectively, the "presentation" becomes completely optional, independent to your game logic.

#

In ECS, the way of reasoning is that, as long as we provide enough data, game logic systems will work perfectly well.

#

How or where you get that data to feed these ECS systems is another story.
(And how or where you utilize data produced by these systems is another story too.)