1
\$\begingroup\$

I am using Unity. I have quite a bit of Unity experience, however I am a novice in animation. In the past I have had someone else do character Animation aside from some Camera animation and simple object movement.

In this game I have large 3D Cube-like characters I made in Blender. Now a normal humanoid character will change in shape as they walk. But these block characters however do not change in shape as they move around the world, as they attack, and so on; they are always rigid and block like in shape.

They get around the world by rotating themselves. Most of the time they would move by pivoting on the corners of their shape. Here is an image to show what I am talking about:

Block Character movement Bonus Image: http://i.imgur.com/UXNraho.png

Think of moving a big cube of something heavy in real life by alternating pivoting it on the front two & bottom corners of the cube. That’s how they walk.

So by most means this is very simple animation: no need to alter a mesh’s shape. However I have a few issues that need to be resolved:

  • 1) The objects velocity is discontinuous: its acceleration is jerky. For a normal running humanoid all you have to do is play the animation as they run in a straight line at a constant rate (of course it can get much more complicated). But for these block characters their center is technically swaying back and forth as it moves, take a look at the picture to see what I mean. Also it’s not moving forward at a constant rate, and instead slows down as each “step” comes to an end. This is an issue because animations don’t normally move the object: instead the game’s code actually moves the character’s center while playing animations that are consistent with the object’s movement. But now if I take that approach I would have to figure out how alter the character’s center that is consistent with this rotating block movement, which would be a huge hassle. It would be nice if these animations actually did move the object depending on how the animations would actually move the object, instead of the animation basically just rotating the object in local space while trying to figure out what that movement would mean in global space in code. It may seem that rotating objects around a point in code may be the best solution for this, avoiding Unity’s animation system all together, however it would quickly become a pain to figure out how to do every animation only in code.
  • 2) These block characters come in different sizes. Some are tall, some are wide. Some characters will swing out more (have a larger angle) as they step forward. It would be nice to be able to basically create this animation once and have it able to be applied to different block sizes and stride types. If I were to use Unity’s or Blender’s animation system I don’t know how much I will be able to automate this. For example I want to basically be able to say okay this character takes these wide of steps this fast, and the rest would be figured out from there. Also while the characters move forward via the rotation animation some characters will lift the other three corners off the ground depending on their mass.
  • 3) This kind of goes with the point above, but there may be a bit of randomness in some movements. For example some objects jump in the air, and when they do so they have a small random change in rotation due to unevenness in the jump.
  • 4) These animations need to be fully interruptible. For example if a block is taking a step forward and then suddenly takes on a large force that sends them flying they would do so starting with the orientation they were at when they took on the force. Like rag dolling, except with something completely rigid. Not the most difficult thing on this list.
  • 5) Lastly some movements would be complicated, for example one block character does a mid-air double round house kick.

This movement is more of a game play mechanic than it is cosmetic.

TL;DR: This is my main issue: I am torn between how much to rely on code for these animations and when to use Unity’s (or Blender’s) animation system, if at all.

These are what I see as my options:

1) “Standard Animation”: animate these animations in the animator, painstackingly figure out how to move these objects in global space that is consistent with these unusual animations. So basically have the character be a child of a parent transform, and figure out how to move the parent transform point depending on what animation is playing.

2) Programmatically: forgo the animation system and do all movement in code. May become also time consuming when doing more complicated movements, but maybe not.

3) Something else hopefully??? A smart mix of the two I haven’t through about?

The two options don’t sound great, and I am unsure on which one would be more time consuming. What would you do in my shoes? Is there a good third option I haven’t figured out?

\$\endgroup\$
  • 2
    \$\begingroup\$ How would it look when a block performs a roundhouse kick? \$\endgroup\$ – Philipp Feb 26 '17 at 12:19
0
\$\begingroup\$

If you only wanted to walk, I'd say you could get away with using Transform.RotateAround and simply have some anchor points on the corners.

But since you want more complex animation, and also some randomness, I suggest you use Mecanim. You can use root motion to let the animation drive the movement, eliminating the need to figure this out in code and using parent objects.

To add the randomness in the jump, for example, you can layer the animations in Mecanim. In that case you would make a clean jump, and afterwards an animation of some wiggling movement. Then you can additively add the wiggly movement to the jump using parameters to control the amount.

Since you have different sized cubes, you may want to create two animations for each type; like walking, jumping etc. and again, blend between the two based on their size.

Mecanim can sometimes be a little off when walking in straight lines or if you need to turn exactly 90˚ you want to look into Animator.MatchTarget.

You want to look into using blend trees, layers and parameters in Mecanim.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.