During Week 2 or so of the Winter Term, I was assigned to the "Technical Team" and as such, I reported to Austin to see what new "inventions" I could make for the game. He told me about an idea he had to create a sort of wind-funnel that could interact with the Rag-dolls and lift them into the air. This Dev-Blog post goes into detail about how the Wind-Funnel went from begin just an idea to being one of the key hazards in our game of RagBall.
The fan is composed of a few key components: The Wind Area, The Attraction component, and base model, the activating lever, and the multi-tier system.
The funnel is composed of three cylinders (stack on top of one another) each with a greater radius than the one below it. This creates the slight "spreading out look" (as if the wind is spreading outward as it diffuses upward.
The WindArea script applies a force to any rigid body components that stay within its collider. The cylindrical collider has multiple tiers to it (3 tiers). Essentially, there are three Wind Areas stacked on top of one another.
At the bottom of the tube is the wind area of greatest strength. This serves to launch the Ragdoll into the air quickly and to "conquer" and other forces acting on that Ragdoll at the time of entry. I didn't want a dash ragdoll to simply dash right through the wind funnel, and so this low-leveled portion of the tube has a high "Strength" attribute set within the Unity Inspector.
The middle-tiered cylinder is weaker than the one below it and stronger than the one above. It has enough strength-of-force to "catch" a falling object and reverse the downward trajectory of a rigidbody (due to gravitational acceleration).
The highest-tiered cylinder is wider still in radius and weaker in force. This finishes off the multi-tier system and balances out the forces so that (when without input from the player's controller) the Ragdoll will "hang" at the top of the wind funnel.
Now, because the Ragdoll will always enter the funnel with some initial velocity, what this script accomplishes in practice is that is creates a rotational effect on the body, i.e. a "swirling pool" effect. Ragdolls caught within the funnel spin around the perimeter of the area if they do not apply enough force to escape it.
In order to give the wind area a more realistic feel to it, and to create a bit more interesting game play around the hazard, I looked into other ways I could influence the rigid body of the Ragdoll while it was within the wind funnel.
The attraction funnel script applies a gravitational-like force to whatever object stays within its collider so that the colliding object is drawn towards a particular point. Within this wind funnel object, the attraction point is set to the downwards-center. This draws a rigid body with no other acting forces on it towards the center of the funnel.
The pin lever is how to player is able to trigger/toggle the fan on/off. One of the biggest efforts in getting this Game Object to work properly was handling collision with it. Because out Ragdolls have multiple Rigid Bodies (arms, legs, head, hips, body...etc), multiple collisions with the lever would happen in very quick succession. This meant that when ever an even number of collisions happened, the lever would toggle right back to where it was initially positioned. Only when an odd number of collisions occurred did it appear to be working as intended.
To reslove this issue, I wrote a Coroutine to execute as soon as the first collision with a player occurs. The coroutine "pauses" the lever's ability to collide with other objects and essentially gives the lever a cool down between uses. This way, a player can accurately activate and deactivate the lever without immediately reversing their intended action, and it also adds a bit more stability to the game because it means that the fan cannot be toggled on/off immediately by other players after one player has chosen to activate it.
The Pin Lever was not something that I modeled, but something that I scripted for and hooked up to the rest of the wind-funnel system (along with great efforts from Austin and Peter as well)
The final outcome of the Game Object(WindFunnel) allows the players to reach new heights and get to new locations that they previously had no ability to get to. This lil' guy was able to land on top of the scoreboard by SUPER-jumping through the wind-stream!