I'm trying to put pieces together piece by piece, so what I really wanted, to start with, was just a very simple character controller. Renaissance Coders YouTube channel came to the rescue, with a great, nofrills character controller you can code up in literally about 20 minutes. You can find their tutorial here.
This allowed me to get a simple, functional character controller up in the afternoon, and I completely understand all the pieces. I also added a capsule collider to my avatar mesh (Ethan), so he would collide with the trees as I moved him around. Once I added the capsule collider and set it's offset appropriately, I could turn on gravity on the RigidBody.
One other interesting thing I learned here was that you need to freeze rotation on the rigid body in all three axis. The first time I tried to move poor Ethan, he fell flat on his face, and then I could only move him up and down. We have zero tie-to-ground code here, so if the unit runs up against the tree, for instance, it only slowly moves back down to the ground, based on gravity.
This controller is super simple, and there's a billion lines of code to write here for it to become an game-ready controller, but it fulfills our purpose of being able to move the unit around.
Here's a video:
No comments:
Post a Comment