About LinVelocity (Linear Velocity). And Animation Speed-to-Scale/ RootMotion

So, I have been hearing a lot about LinVelocity: How it can be used to control “RootMotion” in a sense; how it can also control animation speed according to scale or other things, (For instance if the object’s scale is 1.00, it will play its animation at 24FPS, but if its scale is 2.00, it will play its animation at 12FPS, so no motion actuators need to be adjusted).

So I was wondering if there is a tutorial on how to do this. I think a lot of my games could stand a little bit of this, but I haven’t been able to figure it out in the least so far.

Thanks.

P.S. This is the last thing I need to perfect In-Game-Growth for my baby dinosaurs in T. rex World, so solving this would be greatly appreciated.

Linear velocity describes the positional change of an object (typically called “motion”) regarding the build-in physics engine.

It has nothing to do with scaling, nor rotation.
It is independent from the frame rate (it is Blender unit per second)
It has nothing to do with actions or playback speed of actions.

Playing actions and using physics motions are exclusive (unless you play an action as force).

When you want to change the speed of an action playback, you either

  • use the Python API to play an action with speed parameter or
  • you explicitly set the pose to play (e.g. via action actuator in property mode).

According to your description you need this:

  • determine the “size” of the character
    -> determine the motions and actions to play based on the size

It looks like you want to reuse the same setup/meshes/actions for different sizes.

Indeed this can result in unwanted effects, e.g. the (walk cycle) step size increased, but the physics motion did not. So you need to have either more speed, smaller steps or action with lower playback speed. This way the action and the motion would fit together again.

As action playing and motion belongs together, I would start and configure them with python. The Action actuator only supports a playback speed of 1.0. The Python API might be better in this situation:



def playWalkCycle(controller):
    characterArmature = controller.owner
    characterSize = ...
   
    playbackSpeed = characterSize * ... # however you want to transform size to playback speed
    characterArmature.playAction("dinosaur.small.walking", 1, 50, 0,0,0, KX_ACTION_MODE_LOOP, 0.0, 0, playbackSpeed)


You call this every time you want to let the character walk. [Do not forget to stop the animation when the character stops!]

to setup the motion I suggest to use a different snippet. Here we setup a motion actuator. How you move the character is up to you.


def configureForwardMotion(controller):
    characterPhysics = controller.owner
    characterSize = ...

    motionActuator = controller.actuators["forward motion"]
    configuredLinearVelocity = motionActuator.linV
    configuredLinearVelocity.x = characterSize * ... # however you want to transform size to forward speed
    motionActuator.linV = configuredLinearVelocity


This code adjusts the motion according to the current size. You do this once after each size change.

When you want to let the character move forward you just activate the actuator (via any controller you like).