Giving Personality to Procedural Animations using Math

t3ssel8r
29 Jun 202215:29

Summary

TLDRこのビデオスクリプトでは、伝統的なベクターアニメーションにおける補間曲線の概念から始まり、プロシージャルアニメーションにおけるキーフレームなしの柔軟性を紹介します。ゲームにおけるキャラクターの動きを制御する際に、逆運動学を使用し、リアルタイムの要求に応じて応答する例を説明します。さらに、補間曲線と同様の直感的な抽象化を用いて、動的な反応性を失わずに慣性とエネルギーを加える方法を提案し、数学的モデルを使って動きの特性を調整する方法を解説します。UnityのSmoothDamp関数を含む実践的な例を通じて、リアルタイムでの方程式の解決方法と、安定性を確保するための技術的な分析を紹介しています。

Takeaways

  • 🎨 伝統的なベクターアニメーションでは、補間曲線という概念があり、これはアニメーションのキーフレーム間の動きを制御するものです。
  • 🛠️ プロシージャルアニメーションでは、キーフレームの概念を排除することで、状況に応じた動きが可能になります。これはゲームにプロシージャルアニメーションを組み込む主な理由の一つです。
  • 🤖 ゲームにおけるキャラクターの動きは、逆運動学を使用してリアルタイムの移動と向き変更の要求に応答するように制御できます。
  • 🔗 補間曲線を使わずに動的な反応性を維持しながら、慣性のようなものを得る方法を探求しています。
  • 📉 動的な入力xに対して、特徴的な動きをもたせた動的な出力をyとして生成する問題を定義しています。
  • 🔄 第二階の微分方程式を用いて、動きの特性を定義し、k1, k2, k3というパラメータを用いて様々な動作を作り出します。
  • 📏 f, zeta, rという3つの新しい変数を定義し、それらをシステムの動きの設計パラメータとして使用します。
  • 🎚️ fは自然周波数、zetaは減衰係数、rは初期応答を制御する値です。これらを使ってキャラクターの動きの特性を調整できます。
  • 👾 実時間でこの方程式を解決し、プロシージャルアニメーションの動きを実践的に使用するアプローチを探求しています。
  • 📚 セミインPLICIT Euler法という、Euler法のバリエーションを使って、微分方程式を数値的に解決する方法を紹介しています。
  • 🚫 周波数がフレームレートに比べて高すぎると、システムが不安定になる問題があります。これはより技術的な分析によって解決可能です。
  • 🔍 状態空間表現を使用して、システムの安定性を解析し、時間ステップTが安定性閾値以下であることを保証する制約を導出します。
  • 🛑 時間ステップが大きすぎる場合、安定性閾値に基づいて小さなステップに分割することで、計算を制御します。
  • 🎮 ゲームエンジンでは、安定性を確保するためにk2を制限するか、極-零点一致法を使用してフレームごとにk1とk2の値を計算することができます。
  • 🌐 f, zeta, rのようなシンプルなパラメトリック_motionモデルを使用することで、ゲームプレイ情報を伝えるための動きのバリエーションを簡単に実装できます。

Q & A

  • どのような概念が「補間曲線」として伝統的なベクターアニメーションに存在していますか?

    -「補間曲線」はアニメーションのキーフレーム間の動きを記述する概念で、その形状に応じて動きをゆっくりと開始したり、ゆっくりと終了したり、キーフレームを予測したり、オーバーシュートさせたりすることができます。

  • アニメーション曲線の選択はどのように動作の感覚に影響を与えることがありますか?

    -アニメーション曲線の選択は、運動の慣性とエネルギーの感覚に大きな影響を与え、アニメーターには運動を表現する上で多くの芸術的な表現力を与えます。

  • プロシージャルアニメーションにはどのような特徴がありますか?

    -プロシージャルアニメーションはキーフレームの概念を全く排除し、システムが状況に応じて動くように自由にします。この柔軟性はゲームにプロシージャルアニメーションを組み込む主な理由の一つです。

  • 逆運動学とは何であり、どのように使われますか?

    -逆運動学は、キャラクターがリアルタイムの移動と向きを変える要求に応じて体と脚を動かす技術です。マウスで制御され、オンラインで実装方法に関するチュートリアルが見つけられます。

  • プロシージャルアニメーションでは補間曲線を使わずに慣性のような感覚をどのように表現できますか?

    -プロシージャルアニメーションでは、補間曲線に類似する直感的な抽象化を使用して慣性のような感覚を実現しつつ、キーフレームなしシステムの動的な応答性を失わずにすることができる。

  • ゲームにおける動的な入力xに対して、どのように動的な出力をyとして追跡するようにシステムを設計しますか?

    -ゲームからの動的な入力xに対して、入力xを追跡する一方で、運動の感じを伝える特質を持つ動的な出力をyとしてシステムを設計します。最も単純なケースでは、y=xであり、システムは与えられた入力に固く従います。

  • 第二オーダーシステムとは何であり、どのように現実世界の力学的運動と関連していますか?

    -第二オーダーシステムとは、最高到達する時間微分の次数が2である関係のことを指し、現実世界の力学的運動は第二オーダーであり、力を加えると加速度の変化、すなわち位置の二階微分に影響を与えるという事実に関連しています。

  • f, zeta, rという3つの新しい変数を定義するにあたり、それぞれがシステムの動きのどの部分を制御するのに使われますか?

    -fはシステムの自然周波数で、入力の変化への応答速度と振動する傾向の周波数を記述しますが、運動の形状には影響しません。zetaは減衰係数で、システムが目標に達する様子を記述し、rはシステムの初期応答を制御します。

  • UnityのSmoothDamp関数とは何であり、どのように使われますか?

    -UnityのSmoothDamp関数は、減衰係数が正確に1であることを特徴とする関数で、これはクリティカルダンピングと呼ばれ、目標値に向かって徐々に安定する動きを実現します。

  • 半インPLICIT Euler法とはどのようなアルゴリズムで、どのように運動方程式をリアルタイムに解決するのに使われますか?

    -半インPLICIT Euler法は、Euler法の変種であり、システムの運動方程式をリアルタイムに解決するために使用されます。位置と速度の推定値を更新し、最後の推定値を使って加速度の計算を行います。

  • 物理ソルバーが不安定になる原因は何であり、どのように解決策を見つけるに至りますか?

    -物理ソルバーが不安定になる主な原因は、大きなタイムステップとパラメータの比較により、エラーが蓄積され、そのエラーが自己増殖し始めることです。問題を標準形式に整理し、状態空間表現を使用して状態変数の影響を分析することで、解決策を見つけることができます。

  • ゲームエンジンで不都合な事態を防ぐためには、どのようなアプローチを取ることができますか?

    -ゲームエンジンで不都合な事態を防ぐためには、最大安定タイムステップを計算し、実行時にタイムステップをそれに比較することができます。タイムステップが大きければ、安定性しきい値を下回る小さなステップに分割することができます。

  • f, zeta, rパラメータを使用してゲームプレイ情報を伝える方法とはどのようなものですか?

    -f, zeta, rパラメータを使用してキャラクターの動きに異なるパラメータを割り当て、その状態の変化をプレイヤーに伝えることができます。これにより、意識、健康状態、ステータス効果などに基づいてキャラクターの動きが変化し、プレイヤーに状況を伝えます。

  • 極-零_matching方法とは何であり、どのような利点がありますか?

    -極-零_matching方法は、タイムステップに基づいてk1とk2の値をフレームごとに計算する手法で、非常に高速な動きに対してより正確な結果を生成する利点がありますが、追加の計算コストがかかるという欠点もあります。

Outlines

00:00

🎨 アニメーションの表現力:補間曲線と手続き型アニメーション

第1段落では、伝統的なベクターアニメーションにおける補間曲線の概念とその重要性が説明されています。補間曲線はアニメーションのキーフレーム間の動きを制御し、運動の慣性とエネルギーを表現するのに役立ちます。手続き型アニメーションではキーフレームを排除し、状況に応じた動きを実現できます。これはゲームに組み込む主な理由の一つです。例えば、ゲーム内の小さなロボットキャラクターが、リアルタイムの移動と向きの変更に応じて逆運動学を使用して体と脚を動かす様子が紹介されています。手続き型アニメーションでは補間曲線を使わずに動的な反応性を失わずに慣性のようなものを得る方法を探求しています。

05:04

🔧 動的な出力の実現:第二階数システムとパラメータの調整

第2段落では、動的に変化する入力xに対して、運動の感じを伝える特性を持つ動的な出力yを生成する方法について詳細に説明されています。単純なケースから始めて、入力に応じてシステムがどのように動くかを数学的に表現しています。第二階数システムとして知られる関係式に速度と加速度の項を加えることで、さまざまな興味深い動作を作り出します。しかし、これらのパラメータk1, k2, k3がどのように動作に影響を与えるかを直感的に理解することは難しいです。そこで、ステップ応答を使ってシステムの動的な特性を可視化し、新しい変数f, zeta, rを定義して、これらのパラメータを直感的にコントロールする方法を提案しています。

10:08

🛠 実時間での方程式の解決:半顕式オイラー法と安定性の確保

第3段落では、実時間で方程式を解決し、それをゲームに実践的に適用する方法について探求しています。オイラー法の変種である半顕式オイラー法を紹介し、その精度と複雑なベルレ積分と同等であることについて説明しています。状態変数として位置と速度を割り当て、フレームごとの更新ループを作成する方法を説明しています。しかし、共振周波数fがフレームレートに比較して高すぎるとシステムが不安定になる問題があります。この問題を解決するために、数学的な分析を行い、状態空間表現を使用して安定性閾値を計算し、大きなタイムステップが原因でエラーが蓄積されるのを防ぐ方法を提案しています。

Mindmap

Keywords

💡補間曲線

補間曲線とは、アニメーションのキーフレーム間の動きを制御する概念です。この曲線の形状によって、動きを遅く始めたり、遅く終わらせたり、キーフレームに先んじたり、オーバーシュートしたりする動きを作り出せます。この概念は、ビデオの主題であるアニメーションの動きの表現において非常に重要であり、慣れ親しんだ技法として紹介されています。

💡プロシージャルアニメーション

プロシージャルアニメーションとは、キーフレームという概念を排除してシステムが状況に応じて動くアニメーションの手法です。ビデオでは、ゲームにおけるキャラクターの動きにこの手法が用いられており、リアルタイムの要求に応じて逆運動学を使ってボディと脚を動かす様子が説明されています。これは、アニメーションをより動的かつ応答性高くする一つの方法として紹介されています。

💡逆運動学

逆運動学は、物体の最終的な位置や姿勢を決めてから、その物体の関節や部分がどのように動くべきかを計算する技術です。ビデオでは、ロボットキャラクターがリアルタイムの移動と向きを変える要求に応じて逆運動学を用いている例が挙げられており、これは動的なアニメーションを実現する上で重要な技術とされています。

💡第二秩序システム

第二秩序システムとは、位置の二階微分(加速度)を含む力学的なシステムを指します。ビデオでは、実際の物体の動きが第二秩序であると説明されており、これは力が加速度に作用するというニュートンの運動の法則に基づいています。このシステムを使って、異なるパラメータを調整することで多様な動きを作り出す方法が紹介されています。

💡自然周波数

自然周波数は、システムが変化に応答する速度や、自然振動する周波数をHz(周期毎秒)で表したものです。ビデオでは、自然周波数がシステムの振動の頻度を決定し、それがアニメーションの自然さに寄与すると説明されています。

💡減衰係数

減衰係数は、システムが目標値に到達する様子を決定するものです。ビデオでは、減衰係数が0の時、振動が止まらない無減衰状態から、1より大きい時、振動せずに目標に向かって徐々に安定する状態まで、システムの振動の様子を調整するパラメータとして紹介されています。

💡初期応答

初期応答は、システムがxの変化に即座に反応するかどうかを制御するパラメータです。ビデオでは、rという値として紹介されており、rが正の値である場合、システムはxの動きにすぐに反応する様子が示されています。これは、キャラクターの動きをよりリアルに表現する上で重要な要素です。

💡イーラメーター法

イーラメーター法は、常微分方程式を数値的に解く手法の1つであり、ビデオでは特に半陳的イーラメーター法が紹介されています。これは、キーフレームなしのシステムの動きをリアルタイムでシミュレートする際に用いられます。ビデオでは、この手法を使って、アニメーションのパラメータをリアルタイムに調整し、安定した動作を確保する方法が説明されています。

💡状態空間表現

状態空間表現とは、システムの現在の状態をベクトルとして表現し、その状態が次の時間ステップでどのように変化するかを記述する数学的な手法です。ビデオでは、状態空間表現を使って、イーラメーター法が安定する条件を求める方法が紹介されており、これはアニメーションの安定性を確保する上で重要な役割を果たしています。

💡極座標匹配

極座標匹配は、ビデオで紹介されている高度な技術手法で、k1とk2の値をフレームごとに計算して、非常に高速な動きに対してより正確な結果を得る方法です。これは、アニメーションの精度を高めるために使用されるが、計算コストが増加することがあると同時に説明されています。

Highlights

在传统矢量动画中,插值曲线的概念用于描述动画关键帧之间的运动方式,影响动画的惯性感和能量感。

程序化动画通过完全摆脱关键帧的概念,使系统能够根据情况需求自由移动,增加了适应性。

通过使用逆动力学,游戏中的角色能够实时响应移动和改变方向的请求。

在没有关键帧输入的情况下,无法使用插值曲线增加惯性感,需要类似插值曲线的直观抽象。

动态输入x与动态输出y之间的关系,以及如何通过方程引入速度和加速度项来引入有趣的动态。

第二阶系统的概念,以及如何通过牛顿第二定律理解现实世界中的机械运动。

通过调整k1, k2, 和 k3的值,可以产生多种不同的动态行为。

定义了f(自然频率)、zeta(阻尼系数)和r(初始响应)三个新变量,作为系统运动的设计参数。

f, zeta, 和 r各自控制系统响应的不同方面,提供了对动态行为的直观理解。

使用f, zeta, 和 r参数,可以调整角色动画的运动特性,如身体倾斜和头部滞后。

介绍了半隐式欧拉方法,用于实时解决微分方程,保持动态响应性。

通过状态变量(位置和速度)的更新,展示了半隐式欧拉方法的迭代过程。

当共振频率f相对于帧率过高时,系统可能变得不稳定,导致无限增长。

通过分析状态转移矩阵A,可以确定系统稳定性的条件。

系统稳定时,状态转移矩阵A的特征值的模必须小于1。

通过计算最大稳定时间步长T critical,可以在运行时避免系统不稳定。

介绍了极零匹配方法,用于根据时间步长计算k1和k2的值,以提高快速移动的准确性。

使用简单的参数运动模型,如f, zeta, r模型,可以为游戏角色的状态(如警觉、健康、状态效果)提供不同的运动参数。

通过这些参数的调节,可以向玩家传达游戏角色的情况,这是一种成本低廉且易于迭代的方法。

Transcripts

play00:00

In traditional vector animation, there is a concept called interpolation curves,

play00:04

which describes the way we move between one animation keyframe and the next

play00:10

Depending on the shape of this curve, we can control motion to slowly ease in,

play00:14

to slowly ease out, or even to anticipate and overshoot the keyframe

play00:20

The choice of animation curves can greatly affect the feeling of inertia and energy in the motion

play00:26

This grants the animator a good deal of artistic expression in describing motion

play00:31

while keeping the number of keyframes economical

play00:35

In procedural animation, however, it can be very powerful to do away with the concept of

play00:39

keyframes entirely, freeing the system to move however the situation demands

play00:45

This adaptability is one of the main reasons to incorporate procedural animation in games

play00:51

For example, in the game I’m working on, I have this little robot character which moves its body

play00:56

and legs using inverse kinematics in response to realtime requests to move and change orientation

play01:04

I’m controlling it with my mouse here, and you can find tutorials for how to

play01:06

and you can find tutorials for how to implement this sort of thing online

play01:11

In game, this same flexibility allows the character to immediately respond

play01:15

to changing gameplay situations

play01:20

This is pretty nice, but because we don’t have keyframes for these inputs,

play01:24

we can't really use interpolation curves to add that sense of inertia

play01:28

What we’d really like is the ability to achieve something like this,

play01:33

using an intuitive abstraction similar to interpolation curves,

play01:36

but without losing out on the dynamic responsiveness of a keyframe-free system

play01:43

Let’s start off by describing the problem we want to solve a bit more precisely

play01:49

Given some dynamically changing input x from our game world,

play01:53

we want to produce some dynamic output y which tracks the input x, but is imbued with

play01:58

some sort of characteristic that conveys the way that we want the motion to feel

play02:04

In the simplest case, y=x, and our system rigidly conforms to whatever input we give it

play02:11

This isn’t very useful on its own, but it is a good starting point

play02:16

Whatever changes we make to this equation, we’ll want to ensure that in the long term,

play02:20

when x isn’t changing, y should eventually settle at x

play02:25

To introduce the possibility for interesting dynamics,

play02:28

let’s add some velocity and acceleration terms, represented here as

play02:32

first and second order derivatives with respect to time, scaled by some values k1, k2, and k3

play02:40

The dot notation here is just a shorthand way of writing time derivatives, which

play02:44

you may have also seen written like this, or this

play02:50

This type of relationship involving up to a second order time derivative

play02:53

is known as a second order system

play02:56

Mechanical motions in the real world tend to be second order, which you can think of as

play03:01

being related to the fact that forces act on acceleration, the second derivative of

play03:05

position, as described by Newton’s second law These forces usually arise out of stiffness,

play03:12

where they are a function of displacement, or out of friction, where they are a function of

play03:16

velocity, hence our choice of terms

play03:20

For example, this is the equation of motion of a rigid body

play03:23

being dragged along one axis through a linear damped spring

play03:28

And this is the equation of motion for the SmoothDamp function in Unity

play03:33

By playing around with these values k1, k2, and k3, we can generate a whole host of different

play03:39

interesting behaviors, but as an artist, it might not be very intuitive

play03:43

how these values map to those different behaviors

play03:47

First, let’s simplify the visualization to look at the response to a single sudden change in the input

play03:54

The resulting output is known as the step response, which is a standard way

play03:58

of visualizing the dynamics of a system, and captures the essence of the system’s behavior

play04:05

Next, using k1 k2 and k3, we’ll define 3 new variables: f, zeta, and r

play04:12

We’ll use f, zeta, and r (which I’ll explain in a moment)

play04:16

as the design parameters for the system’s motion

play04:20

Under the hood, we can use them to compute k1, k2, and k3

play04:26

In this new parameterization of f, zeta, and r, each term controls something

play04:31

that we can develop some reasonable intuition about

play04:35

f is the natural frequency of the system measured in Hz, or cycles per second

play04:40

It describes the speed at which the system will respond to changes in the input, as well as the

play04:45

frequency the system will tend to vibrate at, but does not affect the shape of the resulting motion

play04:52

zeta is known as the damping coefficient

play04:54

It describes how the system comes to settle at the target

play04:58

When zeta is 0, vibration never dies down, and the system is undamped

play05:04

Between values of 0 and 1, the system is underdamped, and will vibrate more,

play05:08

or less, depending on the magnitude of zeta

play05:12

When zeta is greater than 1, the system will not vibrate,

play05:15

and instead slowly settle toward the target x, depending on the magnitude of zeta

play05:21

The SmoothDamp function in Unity uses a zeta equal to exactly 1 which is known as critical damping

play05:28

r is a value which controls the initial response of the system

play05:32

When r is 0, the system takes time to begin accelerating from rest

play05:37

When r is positive, the system reacts immediately to movement in x

play05:42

When r is greater than 1, the system will overshoot the target

play05:47

When r is negative, the system will anticipate the motion

play05:51

When modeling a mechanical connection, a value of 2 for r is typical

play05:57

Now, as artists, we have all we need to start playing with the

play06:00

characteristics of the motion of our procedurally animated object

play06:04

If we want to control the settling behavior of the system, we can play with zeta

play06:09

If we want to control the initial response of the system, we can play with r

play06:14

If we want to control how fast or slowly the system behaves, we can play with f

play06:22

Coming back to this robot character, you can see I used an underdamped movement for the

play06:26

body with zeta of 0.5, and r of -2 to give it some anticipation before fast movements

play06:33

For a bit of extra flavor, I tilt the body towards the target position,

play06:37

to further hint at the intent behind the motion I want the turning to be smooth, so for the body

play06:43

orientation I use a zeta of 1 and r of 0 I do the same for the head orientation,

play06:49

but with a smaller f, to make it lag behind the body as a sort of secondary motion

play06:54

The cables are animated with a little trick that I explained over on twitter a while ago

play07:03

Let’s now look at an approach for solving this equation in real-time,

play07:06

so that we can begin using it in practice

play07:10

There are many ways of numerically solving differential equations

play07:13

such as our second order one, but a particularly straightforward one is called Euler’s method

play07:19

Today, I will present a slight variation known as the semi-implicit Euler method,

play07:24

which, for our system, happens to have the same accuracy as the more complex Verlet integration

play07:32

First, we need to allocate some state variables: position and velocity

play07:36

These are our estimates of y and its first derivative

play07:40

At timestep 0, they need to be initialized to some initial values

play07:45

Now, when the game is running, we’ll want to iteratively update these variables each frame

play07:50

Let’s call the amount of time that passes between frames T

play07:55

First, we update the position estimate by taking the previous iteration’s position  

play08:00

and adding T times the velocity

play08:04

Next, we update the velocity by taking the previous iteration’s velocity

play08:08

and adding T times the acceleration

play08:11

To compute this acceleration, recall our equation of motion

play08:15

We can solve for acceleration here

play08:19

And substitute in our most recent estimates of position and velocity

play08:24

Note that in semi-implicit Euler, we are using the updated position to compute velocity,

play08:29

which is slightly different from the regular Euler method where we use the previous frame’s position

play08:36

In the case that the input velocity, x dot, is unknown, we can also estimate it using historical

play08:42

measurements, for example, by approximating it as the average velocity since the previous sample

play08:48

This algorithm naturally translates almost line by line into code

play08:55

If we were to implement this in-game, we would see that it does work as designed

play09:00

I hooked up the code to allow for f, zeta, and r to be changed in real time,

play09:04

and the system responds appropriately

play09:13

There is one big issue that we’ll run into after a bit of experimentation though

play09:17

Set the resonant frequency f too high relative to the frame rate, and the system becomes

play09:22

completely unstable, launching itself to infinity

play09:27

While it’s possible to simply keep f low enough such that this type of glitch is unlikely,

play09:32

in a game engine, we would really like to have a stronger guarantee that something like

play09:35

this doesn’t happen in corner cases, such as a lag spike

play09:39

causing the time step to be much larger than anticipated

play09:42

This is a problem that can be solved, but to understand it properly, we’ll have to

play09:46

get a bit more technical with our analysis

play09:50

The reason why physics solvers like Euler’s method can become unstable is that fundamentally,

play09:55

they are feedback systems whose outputs from one iteration, here y and its derivative,

play10:00

are fed back into later iterations of the computation

play10:04

When the time step between frames is too large compared to the parameters,

play10:07

it will start accumulating errors over time

play10:10

Beyond a critical threshold, these errors will start to compound on themselves,

play10:15

quickly leading to catastrophic failure

play10:17

To compute this threshold, we’ll need to organize the problem into a more standard form

play10:22

What we want to do is write the values of our state variables at frame n+1

play10:26

in terms of our state variables at frame n

play10:30

We can do this by substituting the first equation into the second, so now both our equations

play10:34

have y and its derivative at frame n on the right-hand side

play10:38

Now let’s expand this and collect like terms

play10:42

This is a system of linear equations, which we can write in matrix notation

play10:47

The system, written this way, is known as the state-space representation

play10:52

This matrix A, known as the state transition matrix,

play10:55

describes how each iteration of the state variables influence the next iteration

play11:01

Intuitively, you can imagine that the feedback will be stable

play11:04

If A doesn’t cause the state variables to grow

play11:08

if A was a number instead of a matrix,

play11:10

it would be easier to reason about the effect that it has on the system

play11:14

For example, in this simpler system with only a single state variable and no external forces,

play11:20

each iteration is equal to the previous iteration scaled by A

play11:25

When the magnitude of A is less than 1, the magnitude of y at each iteration

play11:29

will be smaller than the previous iteration, causing the system to stabilize over time

play11:36

When the magnitude of A is greater than 1, the magnitude of y at each iteration will

play11:40

be larger than the previous iteration, so the system will quickly grow beyond control

play11:45

This is what we’d like to avoid

play11:49

In our system, A is a 2x2 matrix, which doesn’t have

play11:52

a magnitude that can directly be compared to 1

play11:56

Instead, it has what we can think of as two separate magnitudes, called eigenvalues

play12:02

We won’t get into it here, but suffice to say that both of these eigenvalues z1 and z2,

play12:07

which are computed by finding the two solutions to this equation, must have a magnitude less than 1

play12:13

for the system to settle over time

play12:16

This is computed like this

play12:19

Which expands to this quadratic polynomial of z

play12:24

Which we can solve using the quadratic formula

play12:29

Our system will be stable when the magnitude of this expression is less than 1

play12:34

Solving this inequality gives us the following constraint,

play12:37

that the time step T must be less than the square root of 4 times k2 plus k1 squared, subtract k1

play12:44

In our code, we can compute this maximum stable time step, T critical,

play12:48

and when running in-game, compare the time step against it

play12:52

If the time step is too large,

play12:54

we can divide it up into smaller steps that are below the stability threshold

play12:58

Taking smaller steps requires performing more computations per frame

play13:03

To avoid this, we might be able to get away with slowing down the dynamics instead

play13:08

In this case, rather than constraining T, we can solve for k2 and constrain that

play13:17

Clamping k2 to be above this value is not physically correct, but recall that our goal

play13:22

here was just to prevent catastrophic failure, not to produce an accurate physics simulation

play13:30

There are, of course, much more esoteric places you can take this analysis,

play13:34

and in a previous draft of this video, I did go a bit further

play13:39

For example, this frame-to-frame jittering behavior that sneaks in when the frequency

play13:43

is sufficiently high, is caused by negative eigenvalues, so if we also take that into account

play13:48

during our analysis, we can impose additional restrictions to ensure it doesn’t happen

play13:56

In my own implementation, in case accuracy is needed, I opt to use a method known as

play14:01

pole-zero matching to compute values for k1 and k2 per-frame based on the time step

play14:07

This produces generally more accurate results for very fast movement,

play14:11

but comes with this additional computation cost that might not suit every application

play14:19

The idea behind using simple parametric motion models

play14:22

like our f zeta r one extends some interesting possibilities

play14:27

Just as an example, we could modulate the values of these parameters

play14:30

to convey gameplay information, so characters could move with different parameters

play14:34

depending on their state of awareness, health, status effects, and so on

play14:39

This would help communicate the situation to players through motion

play14:42

in a way that’s cheap and easy to iterate on

play14:46

In any case, I’ve spent long enough working on this video instead of my game,

play14:50

so

play14:50

hopefully this has been an approachable but substantial introduction to

play14:53

some interesting concepts, or maybe a presentation of some applications of

play14:57

mathematics in an unusual but interesting context

play15:03

As always, thanks for watching

Rate This

5.0 / 5 (0 votes)

Related Tags
ウェブデザインSEO対策コンテンツ戦略ユーザーエクスペリエンスウェブマーケティングオンラインビジネスデジタルマーケティングウェブ開発ウェブテクノロジーインバウンドマーケティング
Do you need a summary in English?