0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PlayMakerで数式を簡単に扱う方法【MathExpressionのススメ】

Posted at

こんにちは、ARエンジニアのせぎゅです!
私はPlayMakerを使ってXRコンテンツを日々制作しています。

今回は、PlayMakerで複雑な数式をシンプルに記述するための便利なTIPSをご紹介します。
STYLYユーザーにもオススメの内容です!

四則演算はFloat Operatorでできるけど…

PlayMakerで基本的な加減乗除を行うには、Float Operatorアクションを使います。

例:10 * 5 の計算

image.png

Float Operatorアクションの設定
- 値1: 10
- 値2: 5
- 演算: Multiply
- 結果: ResultA

結果はResultAに50として保存されます。

複雑な数式になると手間が増える…

例えば 10 * 5 + 20 * 2 のような数式を処理するには、複数のFloat Operatorが必要です。

  1. 10 * 5 → ResultA
  2. 20 * 2 → ResultB
  3. ResultA + ResultB → ResultC

といったように、3つのアクションと中間変数が必要になります。
これでは見通しが悪く、保守性も下がります…

解決策:MathExpressionアクションの活用!

そんなときに役立つのが、非常に便利なアクション
MathExpression です!

このアクションでは、以下のように数式を直接記述できます!

image.png

10*5+20*2

以下のように変数を組み合わせることも可能です!

image.png

ResultA+20*2

このMath Expression、なぜかPlayMakerの公式Action Referenceには載っていません…

私自身、2年間このアクションの存在を知りませんでした。
(もっと早く知りたかった…!)

まとめ

MathExpressionアクションを使うことで、

  • 複雑な数式も1アクションで完結
  • 中間変数が不要
  • ステートがスッキリ整理できる

PlayMakerをもっとスマートに使いたい方は、ぜひこのアクションを試してみてください!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?