Search Unity

Surveyor wheel technique?

Discussion in 'Animation' started by rrh, Jun 13, 2014.

  1. rrh

    rrh

    Joined:
    Jul 12, 2012
    Posts:
    331
    In David Rosen's procedural animation talk here:
    http://www.gdcvault.com/play/1020583/Animation-Bootcamp-An-Indie-Approach

    At about 5:30 he shows what's identified as in the slide as a "stride wheel" and he also calls it the "surveyor wheel technique." The 3rd person shooter demo used what looked like a similar technique for setting the speed of the running animation.

    Does anyone know a thorough explanation of how to approach that? Is it a matter of sitting down and doing the math, "If the radius of the wheel is __ then the diameter is ___ and that means it rotates once I travel ____ so my running animation should play at ___" and at the end of it I have a mathematical formula to calculate the speed I should play my running animation given the current velocity of the player?

    And I would have to choose the diameter of my imaginiary wheel to be twice the distance between one foot plant and the next?

    Has anyone done something like this? Does it sound like there's anything else I'm overlooking?
     
    sebagork likes this.
  2. domjon

    domjon

    Joined:
    Oct 14, 2012
    Posts:
    12
    I've been working at this myself based off the same video. Here's the code I have so far that works fairly nicely:

    Code (CSharp):
    1. lastPosition = new Vector3 (lastPosition.x, 0F, lastPosition.z);
    2. Vector3 currPosition = new Vector3 (transform.position.x, 0F, transform.position.z);
    3.  
    4. float dist = Vector3.Distance (lastPosition, currPosition);
    5. float turnAngle = (dist / (2 * Mathf.PI * wheelRadius)) * 360F;
    6.  
    7. //For visualization. Attach to Transform.
    8. surveyorWheel.Rotate (new Vector3 (0F, -turnAngle, 0F));
    9.  
    10. angleCounter += turnAngle;
    11.  
    12. if (angleCounter > stepDistance)
    13.     angleCounter = 0F;
    14.  
    15. animator.SetFloat("runstage", (angleCounter/stepDistance));
    16.  
    17. if (animator.GetFloat ("runstage") > 1F)
    18.     animator.SetFloat ("runstage", 0);
    19.  
    20. lastPosition = currPosition;
    stepDistance controls how far you want the strides to be.

    In your characters animation controller create a float parameter called "runstage", then create a blendtree inside that has 5 slots with your 2 running animations assigned in this order:
    Run-Pass, Run-Reach, Run-Pass ( check mirrored), Run-Reach (check mirrored), Run-Pass.
    Check Automate Thresholds. Should evenly space them between 0-1.

    Note: For ease, in blender I made Run-Pass, and Run-Reach separate single frame animations... not keyframes.

    Hope this helps!!

    Next up... trying to figure out how to make blendtrees interpolate with curves instead of always being linear >_<
     
    sebagork and Ian-Gungee like this.
  3. Ian-Gungee

    Ian-Gungee

    Joined:
    Jul 11, 2017
    Posts:
    10
    I notice it's been quite a few years since your post. Did you manage to get the animation curves working?
     
  4. sebagork

    sebagork

    Joined:
    Jan 8, 2015
    Posts:
    6
    I'm learning about this now, so, same question to you Ian, Did you manage to get the animation curves working?
    Thank you.
     
  5. rrh

    rrh

    Joined:
    Jul 12, 2012
    Posts:
    331
    I still haven't had reason to use this so haven't got into any more detail that they explained here.
     
    sebagork likes this.