Hi everyone,
Does anybody have experience with Locations such as Towns, Villages, etc. ?
I want to write a check function that checks before placing a nature billboard, if it would intersect with the collider of a building inside locations.
The idea is, to have trees and plants populate locations but not be placed on street tiles and inside of props such as sign posts, buildings and other stuff already placed in towns.
Can anyone point me to the script that places locations into the world map and also tell me what locations are actually called?
I came across the term of RMB blocks and some other blocks which I forgot the name of. Are those the blocks underground in dungeons or are those location blocks in MapPixels?
I am not even sure if I have the necessary params inside as override in my Script. I got the following:
DaggerfallTerrain and DaggerfallBillboardBatch. Will this be enough to do such a check or will I need to import more params for this?
Thank you for any pointer to the right direction!
Writing a collision detection for Nature Billboards with building blocks
- Daniel87
- Posts: 391
- Joined: Thu Nov 28, 2019 6:25 pm
Writing a collision detection for Nature Billboards with building blocks
In Julianos we Trust.
-
- Posts: 371
- Joined: Sun Jun 02, 2019 4:28 pm
- Location: Colombia
Re: Writing a collision detection for Nature Billboards with building blocks
Regarding the RMB blocks and RDB blocks:
RMB blocks are the blocks towns, cities, and other exterior locations. Each RMB block is composed of a few buildings, you can think of them as individual city squares. Each city is made out of a rectangular array of different RMB blocks. RDB blocks are the blocks used for interior locations. Dungeon blocks are a kind of RDB block that are designed to snap together to form a larger location, so every dungeon is a 2D array of dungeon blocks.
Regarding your larger point. I think there's another way to do what you're trying to do that doesn't involve collission checking. There's this article (https://www.dfworkshop.net/town-populations/) where interkarma describes how he handles NPC movement in towns. He basically used the automap data to create a navigation grid that NPCs follow when deciding where to move to, and excludes tiles occupied by buildings from this navgrid. Then he refined this system to assign each tile a different "weight" depending on its texture (i.e. on top of not walking into buildings, NPCs are more likely to walk on tiles with a road texture, and will try to avoid water tiles)
Perhaps you could access the data from this navgrid and use it to make your mod decide what tiles it can place billboards on? That way you could easily exclude road tiles and tiles occupied by buildings without having to mess with collissions.
RMB blocks are the blocks towns, cities, and other exterior locations. Each RMB block is composed of a few buildings, you can think of them as individual city squares. Each city is made out of a rectangular array of different RMB blocks. RDB blocks are the blocks used for interior locations. Dungeon blocks are a kind of RDB block that are designed to snap together to form a larger location, so every dungeon is a 2D array of dungeon blocks.
Regarding your larger point. I think there's another way to do what you're trying to do that doesn't involve collission checking. There's this article (https://www.dfworkshop.net/town-populations/) where interkarma describes how he handles NPC movement in towns. He basically used the automap data to create a navigation grid that NPCs follow when deciding where to move to, and excludes tiles occupied by buildings from this navgrid. Then he refined this system to assign each tile a different "weight" depending on its texture (i.e. on top of not walking into buildings, NPCs are more likely to walk on tiles with a road texture, and will try to avoid water tiles)
Perhaps you could access the data from this navgrid and use it to make your mod decide what tiles it can place billboards on? That way you could easily exclude road tiles and tiles occupied by buildings without having to mess with collissions.
Last edited by imsobadatnicknames on Sun Jan 31, 2021 11:04 pm, edited 1 time in total.
Released mods: https://www.nexusmods.com/users/5141135 ... files&BH=0
Daggerfall isn't the only ridiculously intrincate fantasy world simulator with the initials DF that I make mods for: http://www.bay12forums.com/smf/index.php?topic=177071.0
Daggerfall isn't the only ridiculously intrincate fantasy world simulator with the initials DF that I make mods for: http://www.bay12forums.com/smf/index.php?topic=177071.0
- Hazelnut
- Posts: 3016
- Joined: Sat Aug 26, 2017 2:46 pm
- Contact:
Re: Writing a collision detection for Nature Billboards with building blocks
I think you're missing something major here. Nature flats are cleared for every location (town, city, farm etc) in a rectangle with a spacing to give the place some room. Each RMB block has exterior buildings, but also flats. So when you see a tree in a town, it's because it was placed there in the RMB and doesn't come from the nature flats added to terrain.
Hope that helps explain why you're possibly on the wrong path, but then it would be useful if you were to describe what your overall objective is.
Hope that helps explain why you're possibly on the wrong path, but then it would be useful if you were to describe what your overall objective is.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods
- Daniel87
- Posts: 391
- Joined: Thu Nov 28, 2019 6:25 pm
Re: Writing a collision detection for Nature Billboards with building blocks
Thank you for clarification!
I disabled the clearing rect for Jungle Towns only to check how it looks when the towns get populated by nature billboards and it looks pretty neat.
Now I just try to write a function that checks for collisions with houses and other props, so they will only be spawned on dirt tiles by example.
My approach is, to spawn a disposable gameObject where the plant would be spawned. Then raycast straight down to see if I hit the collider of a house and if so, don't spawn this tree and dispose of that gameObject. Maybe to optimize it, create only one GO, which then gets teleported to the next spawn location and raycasts to check if the path is clear, rather than creating a new GO every time and destroying it again.
This is how it looks when they randomly spawn everywhere and I totally dig that style as it is quite fitting for a nation living deep in the jungle.
I also changed the clearing rect around towns etc. to match the actual size of the location it surrounds. It's kind of weird when a small house in the middle of nowhere has time and energy to clear a huge area of it's surrounding free from any plants.
This way I could actually overlap several clearing rects and, let's say, only spawn flowers close to settlements while trees will stay further away.
I dislike the symmetrical and ever-same clear area around any settlement or dungeon and try to change it.
I disabled the clearing rect for Jungle Towns only to check how it looks when the towns get populated by nature billboards and it looks pretty neat.
Now I just try to write a function that checks for collisions with houses and other props, so they will only be spawned on dirt tiles by example.
My approach is, to spawn a disposable gameObject where the plant would be spawned. Then raycast straight down to see if I hit the collider of a house and if so, don't spawn this tree and dispose of that gameObject. Maybe to optimize it, create only one GO, which then gets teleported to the next spawn location and raycasts to check if the path is clear, rather than creating a new GO every time and destroying it again.
This is how it looks when they randomly spawn everywhere and I totally dig that style as it is quite fitting for a nation living deep in the jungle.
I also changed the clearing rect around towns etc. to match the actual size of the location it surrounds. It's kind of weird when a small house in the middle of nowhere has time and energy to clear a huge area of it's surrounding free from any plants.
This way I could actually overlap several clearing rects and, let's say, only spawn flowers close to settlements while trees will stay further away.
I dislike the symmetrical and ever-same clear area around any settlement or dungeon and try to change it.
In Julianos we Trust.
- Hazelnut
- Posts: 3016
- Joined: Sat Aug 26, 2017 2:46 pm
- Contact:
Re: Writing a collision detection for Nature Billboards with building blocks
No problem, glad it helped.Daniel87 wrote: ↑Sun Jan 31, 2021 9:34 pm Thank you for clarification!
..snip...
I also changed the clearing rect around towns etc. to match the actual size of the location it surrounds. It's kind of weird when a small house in the middle of nowhere has time and energy to clear a huge area of it's surrounding free from any plants.
This way I could actually overlap several clearing rects and, let's say, only spawn flowers close to settlements while trees will stay further away.
I dislike the symmetrical and ever-same clear area around any settlement or dungeon and try to change it.
Be aware that the clearing around towns is used by travel options to provide the paths to circumnavigate locations, so depending on how you erased them it may break that part of the mod. You'd need to test it.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods
- Daniel87
- Posts: 391
- Joined: Thu Nov 28, 2019 6:25 pm
Re: Writing a collision detection for Nature Billboards with building blocks
Oh, I didn't know! Thank you! I will definitely check that out later on.Hazelnut wrote: ↑Sun Jan 31, 2021 11:10 pmNo problem, glad it helped.Daniel87 wrote: ↑Sun Jan 31, 2021 9:34 pm Thank you for clarification!
..snip...
I also changed the clearing rect around towns etc. to match the actual size of the location it surrounds. It's kind of weird when a small house in the middle of nowhere has time and energy to clear a huge area of it's surrounding free from any plants.
This way I could actually overlap several clearing rects and, let's say, only spawn flowers close to settlements while trees will stay further away.
I dislike the symmetrical and ever-same clear area around any settlement or dungeon and try to change it.
Be aware that the clearing around towns is used by travel options to provide the paths to circumnavigate locations, so depending on how you erased them it may break that part of the mod. You'd need to test it.
Does travel options use the rect that is also used for clearing around towns? Do you know off the top of your head which variable or property the mod used to check this?
In Julianos we Trust.
-
- Posts: 1409
- Joined: Mon Aug 12, 2019 4:32 pm
- Contact:
Re: Writing a collision detection for Nature Billboards with building blocks
Some of these changes your making are small, but man are they massive improvements to immersion and exploration. Thanks.
My Daggerfall Mod Github: l3lessed DFU Mod Github
My Beth Mods: l3lessed Nexus Page
Daggerfall Unity mods: Combat Overhaul Mod
Enjoy the free work I'm doing? Consider lending your support.
My Beth Mods: l3lessed Nexus Page
Daggerfall Unity mods: Combat Overhaul Mod
Enjoy the free work I'm doing? Consider lending your support.
- Daniel87
- Posts: 391
- Joined: Thu Nov 28, 2019 6:25 pm
Re: Writing a collision detection for Nature Billboards with building blocks
I am now going with the Automap approach, but man am I struggling since hourse with this.
When I borrow the mesh material from the automap, it is always the one of the location that the player is currently visiting. Is there a function of the automap that I can call where I input the MapPixel and it will output an Automap Mesh texture or something like that? I need the automap mesh texture on the fly, while creating the billboards for a particular MapPixel. An of course the player is always quite far away from new MapPixels being generated, so the current ExteriorAutomap will never match the city layout of a MapPixel that is currently generated.
When I borrow the mesh material from the automap, it is always the one of the location that the player is currently visiting. Is there a function of the automap that I can call where I input the MapPixel and it will output an Automap Mesh texture or something like that? I need the automap mesh texture on the fly, while creating the billboards for a particular MapPixel. An of course the player is always quite far away from new MapPixels being generated, so the current ExteriorAutomap will never match the city layout of a MapPixel that is currently generated.
In Julianos we Trust.
- Daniel87
- Posts: 391
- Joined: Thu Nov 28, 2019 6:25 pm
Re: Writing a collision detection for Nature Billboards with building blocks
Thank you
Glad you like them! I do that stuff as I encounter it. Mostly playing around with variables and always encountering something new that might look good when properly tweaked. But this one right now is a hard nut. Spent hours without moving forward, as the automap feature is something I am 100% unfamiliar with and that gives me a strong headache haha.
In Julianos we Trust.