Room design and evaluation – Week 17

I have finished designing the room for the toy town. I used the same system as my normal map for the PCG wood texture to make a wall paint normal so they had some texture and seemed less flat. There are now three light sources for the scene, excluding the lamp posts and traffic lights. I felt it was important to be able to keep the scene brightly lit so that you could see the colours more clearly. However, to be able to show off the lighting in the toy town, I added toggle buttons on the numpad keys 1, 2, and 3 for the three light sources. I have also made a simple free movement script to allow for movement similar to the scene view when playing, which is controlled with wasd for directions, q to descend and e to ascend. The mouse is also locked to the screen to make the first person view work better, so you can press the escape key to stop this.

Below is the room with different lighting configurations. First being without any lights on, second being just the directional light through the window, and third just both lights on the ceiling.

I have made a few final appearance additions, making two more decorative green spots of a flowerbed and hedged area, to help with the more small town vibes by adding more green spaces. I also made a new shop building to provide a utility buildings for the town which can also change colour.

I have also made one final tree with blend shapes with the before and after shown below.

I will now link to my video demonstration of the final town, showing 2 generations so the differences can be assessed. [Link]

 

Evaluation:
I have managed to generate a realistic and interesting town with realistic randomly generated textures and matched my narrative of a model village made for a child to play with using their toys. It is colourful and has variety in structures, including many types and variations of trees and park areas. There is some structure to the towns made with the decision to keep the town hall in the centre along with the school as it would make sense for the most essential places to be at the heart of the town. I have tweaked the spawn rate and made different catagories of structures to spawn so there is variety of particular structures where I want them. More testing would have been valuable to tweak this and maybe make the town larger but the results work well for what I intended.

Cosmetic update and new tree – Week 16

I have made a large amount of visual changes, starting with different coloured materials for the toy so there is more variety in them.

I have also added the random colouring script to all the buildings, excluding the Town Hall on the far right of the images. I felt keeping some consistency with the core of the town would make sense. The first image below is before the code is run and the second is after it has been run.

You may also have noticed that the longer building has now been modified. I have decided to change it into a school as that makes more sense for a town. Below is a view from the back, showing a green area behind. If I had time I’d like to place some smaller toys in there with the target being a ball so they could all chase after a football.

I also made a slight change to the bench decoration, removing the grass and replacing it with a small pavement extension to make it blend in better.

I have also created a new tree model using key shapes to modify the foliage size. Below is a before (top) and after (bottom) of the new tree, showing it’s variety in generation.

I will be adding a few more decorative pieces, the room around the town, and doing final generation tests to critique my work then.

 

Spawning, moving toys and lamps – Week 14

I now have a system for randomly spawning toys on each corner of the pavement, allowing you to set a chance they don’t spawn. They now drift between each point, being assigned a new point along the chain once within a certain range. Some issues I’d like to improve upon with this is that the script I have to make them look at the target is not working correctly. This may still be to do with issue in the armature of the model but I am unsure what they are currently. The toys also react rather dramatically when bumping into things which makes sense as they’re ragdolls, but some modification to them and possibly their speed over longer stretches of pavement may reduce this to a more normal level while keeping their toy-like movement. Possibly setting a destination for the toys could improve on this as well, such as a park, house or cafe. Adding road crossings would further complicate my movement process which is a limitation of it, as colliders line the pavement and the ability to cross would need to involve some way to skip the queue of targets. Many of these design decisions would take more time than I have so I will most likely keep toy movement as an additional task for myself once I am happy with all other aspects.

The lamp posts are now placed on all straight roads with a chance to self destruct so there are not too many, making the streets less barren.

I have achieved most of my initial goals with this system currently, however I believe different variants of toy models or at least colours, more tree model variants, other decorative objects and randomly coloured repeating buildings would add to the town more.

I am also undecided on how the scene around the toy town should look. I was originally considering placing it outside on a picnic rug, but it may make more sense with my narrative for a model town to keep it inside in a child’s playroom, like a dolls house.

Raycast success – Week 13

After lots of attempts to resolve my issues with the raycasting, I have found a solution. As the y position is not considered when making the toy move to a target, I initially tried moving the raycast prefabs above the town so it would definitely not get in the way of any raycasting. However the raycasts still went through each other without recognising the colliders. The solution I found was to instantiate the raycasting prefabs separately by making them spawn after the roads were placed using a script. This seems to have fixed all issues with the raycast, meaning the layermask was not necessary. The path around the entire town is always generated now which I will be using to make the toys walk around. Below is the raycasting prefabs showing how it all links up a path.

I have also made some more decorative elements for the town as I think having just trees appearing randomly would make it less visually distinct.

I have also developed a way to set the scale of the town as it will need to be bigger to fit toys able to walk along the pavement. I have already modified the roads to have colliders around the pavement, creating a path the toys can walk around without falling off onto the road. The movement I have for the toys is still quite shaky and I would like to improve on it, but it’s hard to get realistic movement without animations and just force on a skeleton. Below are the new roads colliders.

I also have plans to add the streetlamps onto more street positions but only have a chance to spawn so they are more evenly but randomly spread out. 

Block buildings and pathing issues – Week 12

I have been trying out different ways of making the buildings, specifically by using basic wooden blocks a child would use to build the buildings, with somewhat nice looking results. The addition of a randomly generated colour for each block makes for a fun and diverse set of buildings. Below is before pressing play (left) and after pressing play (right).

While it does look good, I have however decided against this type of building and decided to stick with the originals. My reasoning for this is that the original houses use about 8 separate blocks, but these new buildings have over 80 separate blocks in each, creating large amounts of lag when they spawn from randomising so many colours and continue to cause issues navigating the scene from the pure amount of objects. I will however be reusing the randomising colours for the original buildings to add some more variety. This test building was valuable to learn the limits of what I’m generating and has caused me to reconsider ways I can improve my town while not stretching resources too much. Below is a gif showing a full rotation of the building.

I have also started work on mapping the path that the toys will follow along the pavements. My current plan is to create a prefab that has a collider and raycasts when awake. They will be placed on the road prefab pavement corners pointing left and fire the first awake in the scene, adding the hit collider to a list and causing that collider to fire at the next one, stopping once a full chain has been made around the town. The main result I need is an ordered list of targets. I can then create a system that sets the toys to go to the next target in the chain, then the next, allowing them to loop around the town.

However, I have already encountered several issues with this. I did a trial run with 4 of these raycasting prefabs pointing at each other in a square and it succeeded, however it doesn’t seem to be working with them when they fire around the town. It seems to collide with the rest of the town, even when there appears to be no colliders in the way. I then set us a layer for the raycasting, which showed a new issue as the raycasts from my raycasting prefabs didn’t seem to be hitting their targets and just past through them. I used a debug raycast to check visually and it showed that they seemed to not detect each other. I will have to continue researching this if I want to make the toys able to walk intelligently around the town. Below is a successful test chain with the debug raycast.

Trees and textures – Week 10

I created a tree model in Blender with a shape key that allows for the foliage to be scaled, then connected code that will randomly choose on this scale, along with the width and height of the tree. This allows for more variety at runtime even with just one tree model. I plan to make other trees that can be changed in this way. Below you can see some examples of before and after running the script.

I have also added these trees in to be randomly distributed across the town, along with some lamp posts on corners. I plan to make some more decorative elements like benches and a park that will randomly spawn for a more unique town.

Another element that should be noticeable is the wooden appearance of the models now. I made a wood texture and normal using Blender. It combined a noise texture with some distortion, colour mixing and scaling to get the natural lines of the wood. It has worked well with the village and makes it look more natural, however some areas now seem darker because of it so I may have to consider how I light the scene, which is partially why I added in lamp posts. The addition of lights could also mean that a day and night cycle would look better if I decide to implement that. I learned about making PCG textures with a noise map from this video [Link].

The concept for my town is that a parent made their child a wooden town for their child to play with, using their stuffed toys. However, I was considering seeing what the town would look like using uniformly sized wooden blocks that kids play with so I will attempt that next to see the result. After that I need to start having my toys walk around the town following a path along the pavement which will make the town feel more populated.

Building placement – Week 9

I now have building placement sorted and was able to randomly distribute 2 types of house along all roads facing the correct way. (Click the gif below for a first person tour of the streets)

I then tested it with larger buildings which went well, however the current system from which I was learning only works when all the wide buildings are placed at the centre and can’t be placed between normal width buildings. This isn’t too much of an issue however, as I wanted the important large buildings to be generally closer the centre of a town, and more residential areas further out from there.

I am happy with the town generation, but it needs more decoration than just buildings to seem more natural and a more random element so it has more differences each generation. Also as I mentioned before I still need a wood texture as the neon colours of the buildings look like plastic rather than the children’s wooden block houses I wanted for my theme.

Town Modelling – Week 8

I have made the road and some of the building I plan to use. They currently have just coloured materials but I plan to make a wooden texture for them so they seem more like models.

I have now also managed to use the road models on the L System and get them all connected properly so there is always a curb around the road. I now need to learn how to place the buildings along this without them overlapping or facing the wrong way.

L Systems – Week 7

I have started work on developing a road system to place the village around. It uses an L system and can be adjusted with a rule and has an adjustable iteration limit. It also has an adjustable chance to ignore the rule to create more variety in generation. Next I will need to make models for the road and the houses and other buildings that will line the street.

To extensively test the system and ruleset, I ran the L system 10 times on iteration limits 1, 2 and 3 and 4 to see which would produce a road system that is spread out well and different each time but wasn’t too clustered and crowded. Below are examples of each limit in order with the chance to ignore a rule set to 0%. With 1 iteration, it still had quite a lot of different variations but I did get the same iteration twice, making it not satisfactory for my town, along with being quite small. With 2 iterations, there was no duplicates and it spread nicely, with smaller streets further from the centre. With 3 iterations it had a few smaller more crowded areas further from the main street, creating more natural group areas as with the 2nd. With 4 iterations things became a bit too crowded and may cause issues with too many roads and not enough spaces for other buildings.

I repeated this test with the chance to ignore the rule at 50% to add more variation, and to judge what percentage chance I wanted for my town to ignore the rule. With 1 iteration it seemed relatively similar and as it was already too small, reducing it’s size made it less viable. With 2 iterations, it looked rather neat, but the slightly crowded areas became much rarer. With 3 iterations, there were still several crowded areas but definitely reduced to a more manageable amount. With 4 iterations it was still too many short turns and corners, making it unsuitable for the town.

I have decided that I will be using 3 iterations as that seemed to produce the best results I think for my town road system, along with a 30% chance of ignoring the rule so there are still more winding streets and some crowded areas, but they aren’t too complex. Next I will need to make models for the road and the houses and other buildings that will line the street.

I initially struggled with this, attempting my own random generation method, however after doing research I knew that an L system would provide the more coordinated randomness needed to make something that still resembles a town. The tutorial series by SunnyValleyStudios on the subject Unity was very helpful in learning how to set one up. [Link]

Bone movement and constriction – Week 6

With my new model I was able to get ragdolling working, this time opting for the automatic ragdoll settings rather than manually adding every characterjoint. I did have to add additional ones for the tail though so that it would swing about. Below is a gif of how they fall. (You may need to click it to view it)

Now to add movement and keep them standing up, I added constrictions that force the shoulders to be a certain height and a force that pulls them in the direction of the target, as taught in the workshops.

It was turned off for that clip, but my adaptation of the LookAt script no longer works with the model and after switching to the workshop script it still has the 90 degree rotation offset which I’m unsure how to fix while also working with local rotation but I shall attempt to.

To improve the movement so that it doesn’t just look like floating I gave a go at a walking script that moves the legs one after the other, however the movement doesn’t look as good with the body not rotating quickly to face the right direction. I also added constraints to the feet to try and keep them on the floor level and the head so it’s always upright.

My next step will be to fix the rotation as I think that’s the final step to having complete toys to walk around the scene. I need to move onto generating the scene with PCG.