Entity collision box

Place to get help with not working mods / modding interface.
Post Reply
eterevsky
Burner Inserter
Burner Inserter
Posts: 10
Joined: Tue Mar 05, 2019 7:46 am
Contact:

Entity collision box

Post by eterevsky »

I am trying to figure out a general way to find the collision box for an entity on the map. Every entity has entity.bounding_box, but this is not the same as the collision box. For entities that are not rotated it looks like you can find the collision box by taking entity.prototype.collision_box and moving it to entity.pos, but from what I can tell this doesn't work for cliffs, because the prototype collision box for cliff doesn't contain orientation.

What is the general algorithm for finding the collision box of an entity?

Bilka
Factorio Staff
Factorio Staff
Posts: 3165
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Entity collision box

Post by Bilka »

" it looks like you can find the collision box by taking entity.prototype.collision_box and moving it to entity.pos" That's what entity.bounding_box does for you. So what exactly is the problem with using that?
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2904
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Entity collision box

Post by darkfrei »

Cliffs have unique name for every rotation.

eterevsky
Burner Inserter
Burner Inserter
Posts: 10
Joined: Tue Mar 05, 2019 7:46 am
Contact:

Re: Entity collision box

Post by eterevsky »

That's what entity.bounding_box does for you.
Bilka, looks like you are right. I was confused and thought and collision and bounding box are two different things. Now I checked again with a few entities, and it looks like bounding_box is just collision_box from prototype plus position. Thanks.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Entity collision box

Post by eradicator »

Bilka wrote:
Sat Jun 08, 2019 4:43 pm
" it looks like you can find the collision box by taking entity.prototype.collision_box and moving it to entity.pos" That's what entity.bounding_box does for you. So what exactly is the problem with using that?
Bounding_box has no description whatsoever in the api doc btw... ;)
Might even be worth writing an additional comment in EntityPrototype.collision_box.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Bilka
Factorio Staff
Factorio Staff
Posts: 3165
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Entity collision box

Post by Bilka »

eradicator wrote:
Sat Jun 08, 2019 5:51 pm
Bounding_box has no description whatsoever in the api doc btw... ;)
Fixed :)
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Post Reply

Return to “Modding help”