In this third MCU Dev blog post I cover the next wave of advanced features I developed after the basic functionality of the package was finished. This set of advanced features focuses on developing water mechanics and prototype flyer animals which move through the water.
The Motor Control Units Development (MCU Dev) package was created to familiarize myself with the Motor Control Unit functionality for the physics based interaction system called Forcibles which the VR framework PuppetJump uses for object interactions. This package was also created to explore some of the capabilities which could become possible by using the Motor Control Units functionality.
This post will cover the following sections:
- Intro
- Basic Tail Flap
- Prototype Flyers and Swimmers
- Landing Zones
- Water Boundary
- Water Level
- Wing Variations
- Spawn Prefab Settings
- Dual Speed Tail Flap
- Jellyfish Prefab
- Squid Prefab
- Flap Based Power
Intro
As a developer, I find that the development process gets streamlines when working with content and functionality that I am familiar with. The more acclimated I am to the core functions and capabilities of the framework or platforms I am working with, the easier and more intuitive it is to build, create, and brainstorm various functionality and features for any project.
With that in mind I started the MCU Dev package. The MCU Dev package is a bundle of assets and code I created while exploring the Motor Control Unit (MCU) feature included in the Forcibles package used to create and control physics based interactions in the PuppetJump framework.
The goal of the MCU Dev package was to familiarize myself with the basics of Motor Control Units, while also exploring what capabilities I could create by leveraging their functionality.
The following blog post covers each step I took during my further exploration of the Motor Control Units functionality.
Basic Tail Flap
Watching the flyers and butterflies navigate their environment in large groups reminded me of the movements of various collections of animals such as swarms of bugs, flocks of birds, and schools of fish. With this idea in mind, it seemed like the next tier of exploration I could look into would be to replicate some aquatic prototypes and behaviors.
In my mind, the first step in turning a flyer into a prototype fish was a straightforward one. I needed to create a tail for the flyers. I was able to accomplish this by making some small alterations to the basic wing flap functionality in order to horizontally rotate a single cube object instead of vertically rotating a set of cube objects. Through these alterations I kept the velocity based movement feature so that the tail would flap faster when the flyer moved faster and would stop flapping when the flyer was not moving.
Prototype Flyers and Swimmers
With the Basic Tail Flap functionality working correctly, I decided it was time to create a set of base grey-box prototypes to use as basic building blocks for any future variations that may be required. I created a grey-box prototype Swimmer prefab out of a flyer with an altered body shape and an added tail. I created the grey-box prototype Wing Flyer prefab out of a flyer with an altered body shape and the addition of a set of wings.
Landing Zones
While testing out the prototype animal flyers in combination with various bait types, I started to notice an issue where all of the flyers would crowd and crash into each other while landing. I also noticed a larger issue where after finishing a landing cycle, the flyers would start navigating toward their next target by moving directly forward. This often meant they were running directly into the bait object they had just landed on, frequently getting them stuck trying to fly through the bait object instead of around it.
To remedy these issues, I created the Landing Zone functionality. The Landing Zone feature uses a collection of designated landing zone locations/positions placed around each bait object. As a flyer starts to initiate a landing at a bait object, this new feature allows them to check if any of the bait object’s landing zones are vacant. If a vacant landing zone is available, the flyer will attempt to land at the position and rotation of the designated landing zone. If no vacant landing zones are available, the flyer will add the bait object to its ignore list and move on to the next target in its list of targets.
Water Boundary
The next step in bringing further realism to this environment and push the Forcibles capabilities even farther was the creation of Water Boundaries. A Water Boundary is a stand-in for a body of water. My idea for this functionality was to create a designated water area which would alter the behavior of the various types of flyers based on their type.
The Swimmer version of flyers would have their behavior altered based on if they were currently inside or outside of the water boundary area when a water boundary was present in the scene. When inside the water boundary, the swimmers would behave normally. When outside of the water boundary, the swimmers would have gravity enabled, causing them to drop to the ground and no longer appear to be able to fly (as they did when no water boundary is present).
The Wings version of flyers would behave normally while outside of the water boundary. But when they entered a water boundary, their forward and rotational velocity gets reduced. This makes them appear as though they had dived into a body of water and behave similarly to how real-world birds do when diving into water.
Water Level
Next up I decided to make the Water Boundary functionality more dynamic. The original water boundary was a preset area which was either on or off. I decided at this point to update its functionality to allow the user to actively change the water level in the scene.
I added a water level control panel to the scene, which displays the current water level relative to the scene as well as giving the user controls which actively change the water level.
With this I also had to make some alterations to some of the functionality controlling the behavior of the flyers as well. I had to add some code to the function which repositions a flyers default target object each time that target is reached. Normally this function would place the target anywhere within the preset boundaries of the scene. But with the addition of water boundaries, I needed to create dynamic alterations to the target reset boundaries based on the type of flyer variation.
While a water boundary is active, the flyer variations with wings had their target reset boundaries set to the area above the water boundary as well as a small overlap below the surface of the water boundary. This prevented the winged flyers from resetting their default targets to the bottom of the water boundary.
Alternatively, the flyer variations with tails had the target reset boundaries set to the water boundary area as well as a small overlap into the air space just above the surface of the water. This prevented the swimming flyers from placing their default target high in the air where they would not be able to reach them.
Wing Variations
In order to test how easy it would be to alter the appearance of the wing based flyers for future applications, I tested out some additional wing textures.
I found, imported, and implemented a handful of textures depicting a variety of types of wings to test this feature with. After a little work I was able to create a selection of wing flyer variations similar to the original butterfly prototype which included a few types of bird wings, bat wings, bee wings, and bone/skeleton wings.
I also tested a use case example of importing the model our team used in the Bees Project and created a flyer variant which utilized this bee model. I found out very quickly while testing this variant that it feels very different being surrounded in VR by a swarm of large butterflies than by a swarm of large bees.
Spawn Prefab Settings
The Prefab Spawner and Dynamic Count Prefab Spawner functionality worked very well for populating the scene with duplicates of whichever prefab they were designated to generate when spawning new prefabs. But I noticed that if I wanted to spawn similar prefabs with unique variations (such as different scales/sizes) I would need to setup a separate prefab for each variation I wanted to generate into the scene.
In order to avoid this drawback, I decided to create a dynamic modular system for altering the objects spawned by a prefab spawner without being required to alter the original prefab being copied. I called this system the Spawn Prefab Settings (SPS) system.
This system allows for the creation of individual and modular sets of instructions that can be added to a Prefab Spawner gameObject. When the Prefab Spawner generates a new copy of the prefab, it checks it’s gameObject for any of these Spawn Prefab Settings (SPS) components. If any are found, the Prefab Spawner applies their unique instructions/alterations to the object which was just spawned.
The first example SPS that I created was a Scale Change SPS. This SPS instructed the Prefab Spawner to change the scale of each object it generated to a randomized value between a preset min/max range. When activated, this SPS made it so that all the generated objects spawned by the Prefab Spawner were slightly different sizes. This added some realistic variation to the groups of flyers and swimmers.
Dual Speed Tail Flap
At this point I had a few new flyer variations in mind, but before creating them I needed to develop a variation on the basic Tail Flap functionality. The original Tail Flap feature rotates a tail cube horizontally at a uniform speed between two preset rotation values. I wanted to create a Tail Flap function which would allow me to set different rotation speed scalar values for each direction of rotation.
So, I created the Dual Speed Tail Flap functionality which does exactly that. When the Dual Speed Tail Flap feature rotates the tail one way it uses one speed scalar value, and when it rotates the tail the opposite direction it uses a different speed scalar value.
The core rotation value for each direction was still linked to the velocity of the flyer that the tail was attached to. However, this functionality will still alter the relative speed of each rotation direction in relation to the velocity of the flyer.
Jellyfish Prefab
Why would I need the Dual Speed Tail Flap feature? Jellyfish. I wanted to create some new variety in the swimming versions of flyers and it turns out that jellyfish look kind of off when they move their tentacles in and out at the same rate. With the creation of the Dual Speed Tal Flap functionality, I could create prototype jellyfish flyers which moved in the classic jellyfish method. The jellyfish prefabs moved all of their tentacles in toward the center in a quick and uniform motion, then slowly let their tentacles drift out away from their body again at a relaxed pace.
Squid Prefab
The creation of the Dual Speed Tail Flap functionality also allowed me to create prototype Squid variants of the swimming flyers. Similar to the Jellyfish prefabs, these Squids moved all of their tentacles in toward the center at a fast pace, then expand their tentacles away from their body at a much slower pace.
Flap Based Power
The final feature I created for this phase of development delt with locomotion alterations. While observing the Jellyfish and Squid prefabs, I noticed that unlike their real-world counterparts, these prefabs moved at the same pace regardless of if their tentacles were expanding or retracting.
To correct this, I created the Flap Based Power functionality. This feature adds a boost to the flyers movement speed when their tail (or in this case tentacles) move a specific direction. This feature also slightly slows the flyers movement speed when the tail/tentacles is moving in the other direction.
When implemented, this feature makes the Squids and Jellyfish flyer variants move with small speed boosts when contracting their tentacles and slightly slow down when expanding their tentacles.
Leave a Reply