Page 1 of 1
collisions
Posted: Wed Jan 22, 2014 10:51 am
by Dysoch
i am trying to add something that i want to be able to place UNDER buildings and belts, but without being to able to place on top of each other!
how to do this?
i already tried with
Code: Select all
collision_box = {{-0.00001, -0.0}, {0.00001, 0.0}},
but sadly that doesnt work! (it does not allow to be build on top of each other, but it also wont build under other buildings xD)
some help would be appreciated
Re: collisions
Posted: Wed Jan 22, 2014 11:12 am
by kovarex
This is sorted out by the collision masks, but these are currently hardcoded for individual entities and not moddable.
The collision layers are now:
- ground-tile
- water-tile
- resource-layer
- floor-layer
- item-layer
- object-layer
- player-layer
- ghost-layer
Every object has it's set of layers (bit-mask) and two objects collide when they share at least one layer.
This enables us to set the logic, that for example, items + player + car can be on transport belt, but buildings can't be on transport belt, and player can walk on top of items and resource/ghost collide with nothing but itself (similar to the thing you need).
This is very performance delicate, so if we make it moddable, the total count of moddable layers would have to be limited, currently the collision mask is 1 byte, and all 8 bits are used, so we would have it to extend to 2 bytes, and let the rest 8 bytes to be used by mod-specified collision layers.
I'm afraid we have way too much work planned for 0.9 to make it now, but we might do it in the future.
Re: collisions
Posted: Wed Jan 22, 2014 11:19 am
by Dysoch
ok good to know, ill just do without the collisions. this will make them placeable on each other, but can be placed under everything else.
mmmm, maybe i can add them to a glob? and let a check run when you build one that will check the location, and i there is 1 present, it will be auto deleted and placed in inventory.
that would work for now right?
Re: collisions
Posted: Wed Jan 22, 2014 1:37 pm
by SilverWarior
Dysoch wrote:i am trying to add something that i want to be able to place UNDER buildings and belts, but without being to able to place on top of each other!
kovarex wrote:The collision layers are now:
- ground-tile
- water-tile
- resource-layer
- floor-layer
- item-layer
- object-layer
- player-layer
- ghost-layer
Every object has it's set of layers (bit-mask) and two objects collide when they share at least one layer.
If I understand this correctly Dysoch would then have to use resource colision layer to achieve what he wants. Right?
Re: collisions
Posted: Wed Jan 22, 2014 1:46 pm
by FreeER
SilverWarior wrote:If I understand this correctly Dysoch would then have to use resource colision layer to achieve what he wants. Right?
well if it was accessible through lua then it would work, but it's not. And from what's been said they'd rather give the modders more options (a second byte for the mask) rather than force them to use the layer's that currently exist. makes me wonder about possible (placement/collision) conflicts between mods though...perhaps some semi-logical names for those layers would be created rather than modders simply arbitrarily choosing one to use? Hm, makes me wonder exactly what the 'floor-layer' is used for though, since the rest seem fairly obvious.
edit:
Dysoch wrote:mmmm, maybe i can add them to a glob? and let a check run when you build one that will check the location, and i there is 1 present, it will be auto deleted and placed in inventory.
Or simply use findentities in onbuiltentity to check for any existing ones at the placed coords, not sure which is actually more efficient in the long run but I'd guess findentities since it would only run when placing them rather than saving a table every few minutes.
Re: collisions
Posted: Wed Jan 22, 2014 7:04 pm
by SilverWarior
FreeER wrote:And from what's been said they'd rather give the modders more options (a second byte for the mask) rather than force them to use the layer's that currently exist.
I think this would only be needed if mod would require new specific layers (existing ones wouldn't fit) desired logic.
FreeER wrote:Hm, makes me wonder exactly what the 'floor-layer' is used for though, since the rest seem fairly obvious.
I'm not sure but I suspect that is used for conveyor belts (item/player to belt colision for making items move).
Re: collisions
Posted: Wed Jan 22, 2014 9:12 pm
by kovarex
FreeER wrote:SilverWarior wrote:Makes me wonder about possible (placement/collision) conflicts between mods though...perhaps some semi-logical names for those layers would be created rather than modders simply arbitrarily choosing one to use?
It would work same as with EntityID, EntityID is internally just 16-bit number and every prototype get assigned the id when you start a new map, this id is used in game to save, for fast indexing prototypes and other stuff, as well as to keep saves small.
(Ofcourse, it is not as simple, as the game needs to remove unused IDS when you remove mod, or assign ids to new prototypes when you load map with new mods, and some other stuff).
Some similar automatic technique would be used for the layers.
Re: collisions
Posted: Wed Jan 22, 2014 11:17 pm
by FreeER
kovarex wrote:Some similar automatic technique would be used for the layers.
Hm...I'm trying to think ahead to when there might be multiple mods using multiple layers at the same time (more than eight in total, but the assignment would have to place some in the same layers because of the 8 bit limit). If one was using a layer for foundation and another was using it for some type of strange quantum building teleporter (or some other building type thing that you wouldn't want colliding with regular entities for whatever reason) the modders probably wouldn't want the automatic assignment to place them in the same layers. That's probably the best example I can come up with off the top of my head. Now I've no idea how much of an issue this might be, which is why I brought it up.
Re: collisions
Posted: Thu Jan 23, 2014 1:37 am
by MF-
Hmmm....
An underground layer..
That might prevent me from "crossing" underground belts and pipes.
I have no idea whether I rely on that "weirdness" or not (And thus no idea whether I would like those unrealistic situations gone or not)