My Portfolio

Thursday, November 25, 2021

Nov 25th - Procedural Animation and Basic Shaders

I did some animation rigging during my last project with the Dune worm and I decided that I wanted to do a really deep dive into it. So far I've been having a lot of fun and feel like the animation rigging package could really help me create some great boss battles and more easily creating cinematic/scripted events. Here are some clips from what I've been experimenting with.

Walker-Bot

My first mini project was to try and create a walking 2-legged robot where the legs automatically move themselves after they exceed a set distance from the main body. It was amazing when I got it work and I could see the legs automatically animating themselves while manually moving the Walker-Bot around. Here is a GIF where you can see me manually moving the body with the legs procedurally animating themselves. 



A quick explanation for how it works is that the body has a Raycast projecting downwards which compares the distance from the body ideal foot position and the current position of the foot. When it exceeds that distance it triggers the movement of the leg which lerps between the current position and the new position in green over time.

I'm using the Two-bone IK constraint in the Animation Rigging package to help with animation.

My current implementation isn't perfect for every situation but it works well enough for fast prototyping. Especially since I can make it move anywhere without needing to do keyframe animations. 

Here is another quick test where I have the body set to both move and follow along a path using Unity's Cinemachine components. 

Spider-Bot

My next challenge for myself was to create a spider-like creature. I know spiders have 8 legs but I decided to just try out 4 to limit the scope challenge. This required me to go back and review trigonometry a bit. Specifically how to calculate angles, work with radians and get vectors for the correct leg positions so that they move to correct spot when rotating the spider.

Here's a sample of me manually controlling its transform and another of it moving along the path.

Manual movement and control of the SpiderBot

Moving along predetermined path

Centipede-Bot

Instead of moving to 8-legs I decided to jump to a Centipede and try combining both the IK rig-constraint along with the damped transform constraint that I previously used on the creating the Dune Worm. It took me a very long time to create a working prototype because I was running into issues with the legs pointing in weird directions when using the Two-bone IK Constraint. I finally realized that the issue was that the legs were trying to match the target Gameobjects rotation and once I disabled that, the legs started positioning themselves correctly.

There's a bit of an issues with the distance checking but otherwise works really well for showcasing a centipede like movement without needing me to manually animate a walk cycle.

Manual Control

Following a Path

I might create a small VR shooter where you have to kill these bots as a game. I've tested it on the Quest2 with the link cable and it seems to run fine without any lag or stuttering. More testing will need to be done with more bots on screen but at the moment it seems pretty promising. It was pretty awesome seeing these giant bots in real life scale as well since I made them pretty big. As a size reference the small cube you see on screen is about the size of a person.

I plan to keep working on a few more animation rigging projects. At the moment I'm thinking of doing a humanoid character project and maybe a few more creature-types such as a bird.

Shaders

I've also been spending time learning and creating my own basic shaders in Unity. I feel like I have a grasp of the basics now but no where near good enough to create any interesting shaders. Specifically, I feel like I need a better grasp on math to really be more comfortable with manipulating shaders. However, some of the basic shaders effects I've created really remind me of Earthbound and makes me want to recreate some Earthbound scenes and gameplay in VR.

No comments:

Post a Comment