モーション、テクスチャアニメの同時実行

Here is the forum to do the questions about how to use to Arbor developer.
Attention point:
  • We can not answer your questions about your project specific issues.
  • We can not answer your questions on Unity's specification issues.
  • Please check Arbor Documentation and ask a question if you still don't know how to use it. If the desired function is not described in the document, it is highly possible that the function does not exist from the beginning, so go to the request forum.

ここは、Arbor開発者へ使い方に関する質問を行うフォーラムです。
注意点:
  • ユーザー様のプロジェクトの仕様上の問題や設計に対する質問には答えられません。
  • Unityの仕様上の問題に対する質問には答えられません。
  • Arbor Documentationを確認の上、それでも使い方がわからない場合にご質問ください。欲しい機能の記載がドキュメントにない場合は機能が元から存在しない可能性が高いので要望フォーラムへ。

Forum rules
Here is the forum to do the questions about how to use to Arbor developer.
Attention point:
  • We can not answer your questions about your project specific issues.
  • We can not answer your questions on Unity's specification issues.
  • Please check Arbor Documentation and ask a question if you still don't know how to use it. If the desired function is not described in the document, it is highly possible that the function does not exist from the beginning, so go to the request forum.

ここは、Arbor開発者へ使い方に関する質問を行うフォーラムです。
注意点:
  • ユーザー様のプロジェクトの仕様上の問題や設計に対する質問には答えられません。
  • Unityの仕様上の問題に対する質問には答えられません。
  • Arbor Documentationを確認の上、それでも使い方がわからない場合にご質問ください。欲しい機能の記載がドキュメントにない場合は機能が元から存在しない可能性が高いので要望フォーラムへ。
huraipannn
Posts: 5
Joined: 2015/12/31 20:19

モーション、テクスチャアニメの同時実行

Post by huraipannn »

新年からお忙しいところ失礼いたします。
コイン落とし、コーディングなどわかりやすいチュートリアルを作成頂きありがとうございます。スクリプト苦手でもできそうな気がしました。


本題ですがMecanimで作成したモーションと同時にテクスチャアニメをつけたいのですがArborでどう実装すればいいのでしょうか?
開始ステートにAnimator State Transionなどをつけたのですが違うようでした。

MecanimではC#で動画のように実装しているのですが、GUIボタンを使わないとテクスチャアニメが実行されません。 https://youtu.be/evD49lNIfL8

GUIボタンを使わず、MecanimのShootが実行されると同時にテクスチャアニメが実行されるようにしたいです。


理想はSDクエリちゃんのやっているモーションとテクスチャアニメです。1:07からがわかりやすいです。
https://www.youtube.com/watch?v=fjks_LTSUms

どうかよろしくお願いします。


Sourcecode:Motion
=============================================
using UnityEngine;
using System.Collections;

public class player : MonoBehaviour {

public Animator anim;
// Use this for initialization
void Start ()
{
anim = GetComponent<Animator>();

}

// Update is called once per frame
void Update ()
{
if(Input.GetKeyDown("1"))
{
anim.Play ("Run",-1,0f);
}
if(Input.GetKeyDown("2"))
{
anim.Play ("Shoot",-1,0f);
}
if(Input.GetKeyDown("3"))
{
anim.Play ("Walk",-1,0f);
}

}
}
=============================================


Sourcecode:TextureAnimation
=============================================
var playerTexture1 : Texture;
var playerTexture2 : Texture;


function OnGUI () {
GUILayout.BeginArea(Rect(5, 5, 100, Screen.height-10));
if (GUILayout.Button("Change")) {
if (GetComponent.<Renderer>().material.mainTexture == playerTexture1) {
GetComponent.<Renderer>().material.mainTexture = playerTexture2;
} else {
GetComponent.<Renderer>().material.mainTexture = playerTexture1;
}
}
GUILayout.EndArea();
}
=============================================
huraipannn
Posts: 5
Joined: 2015/12/31 20:19

Re: モーション、テクスチャアニメの同時実行

Post by huraipannn »

度々失礼いたします。
件名とは別なのですが、インスタンスしたオブジェクトを前に飛ばしたくAdd Force Rigidbodyをつけたのですが前に飛ばないのは違うスクリプトが必要なのでしょうか?
下記の動画を見て頂けると状況がわかりやすいと思います。 https://twitter.com/huraipannn/status/6 ... 057790977
お手数ですがよろしくお願いします。
User avatar
caitsithware
管理人
Posts: 493
Joined: 2015/08/17 12:41

Re: モーション、テクスチャアニメの同時実行

Post by caitsithware »

本題ですがMecanimで作成したモーションと同時にテクスチャアニメをつけたいのですがArborでどう実装すればいいのでしょうか?
現状、Arborではテクスチャを切り替えるBehaviourがないので自作する必要があります。
例えば以下のようなコードになります。

Code: Select all

using UnityEngine;
using Arbor;

public class ChangeTextureBehaviour : StateBehaviour
{
	public Renderer target;
	public Texture texture;

	public override void OnStateBegin()
	{
		target.material.mainTexture = texture;
	}
}
このコードをArborのステートに割り当てて、targetにテクスチャを変えたいRendererを、textureにテクスチャをそれぞれ指定することで、該当ステートに切り替わったタイミングでテクスチャも切り替わるようになります。

ですが、例に挙げられたplayerクラスやTextureAnimationクラスは、Arborを使用しないUnityの基本的な実装方法となっていますので、Unityの基本的な使い方を詳しく調べられた方がよろしいかと思います。
インスタンスしたオブジェクトを前に飛ばしたくAdd Force Rigidbodyをつけたのですが前に飛ばないのは違うスクリプトが必要なのでしょうか?
動画を拝見しましたところAddForceRigidbodyのTargetがNoneになっているため生成したゲームオブジェクトに力が加わらなくなっています。
この場合、InstantiateGameObjectのOutputからRigidbodyを取得し、AddForceRigidbodyのTargetにパラメータを流し込む演算ノードが必要になります。
生成したゲームオブジェクトにAddForceする.gif
生成したゲームオブジェクトにAddForceする.gif (419.97 KiB) Viewed 5041 times
手順は以下の通りです。
  • 適当な場所を右クリックし、「演算ノード作成」をクリック
  • Rigidbody.Getを選択。
  • Rigidbody.GetのGameObjectパラメータの右側にある▼マークをクリックし、Calculatorを選択。
  • InstantiateGameObjectのOutputからRigidbody.GetのGameObjectへドラッグ&ドロップして接続。
  • AddForceRigidbodyのTargetパラメータの右側にある▼マークをクリックし、Calculatorを選択。
  • Ridigbody.GetのRigidbodyからAddForceRigidbodyのTargetへドラッグ&ドロップして接続。
huraipannn
Posts: 5
Joined: 2015/12/31 20:19

Re: モーション、テクスチャアニメの同時実行

Post by huraipannn »

丁寧にご教授ありがとうございます!
おかげでこんな感じにできました。https://youtu.be/qn92yuwzuCI

テクスチャアニメわざわざコードまで書いて頂きすいません。そちらの検証や改めて機能あらいなおしたころTween機能が豊富にありまして今回はTweenTextureOffsetで実装しました。
この機能すごいですね。画面を見ながら小数点、カーブまで調整できて表情だけでなくマップ作りにも重宝しそうです。

インスタンスしたオブジェクトのアニメーションですが演算ノードのRigidbody.Getが1つ目のインスタンスオブジェクトにしかかかりませんでした。なのでインスタンスのソースに戻りZ方向へ進むスクリプトで実装しました。


=============================================
using UnityEngine;
using System.Collections;

public class Shoot_move : MonoBehaviour
{

//float time = 0.3f;
float bulletSpeed = 0.5f;

// Use this for initialization
void Start ()
{
Destroy(this.gameObject, 5);
}
// Update is called once per frame
void Update ()
{
/*
time = time + Time.deltaTime;
if(time >= 0.02f){

time = 0;
*/
transform.Translate(0, 0, bulletSpeed);
}
}
=============================================

今回はどうもありがとございました。Arborのブロック感覚はデザイナーにとってすごい助けになります。AEのコンポジッターとかゲーム経験少なくてもArborならすぐ馴染めそうです。
またなにかありましたらよろしくお願いいたします。

PS.
TweenCanvasGroupAlphaにアルファ値0~1に対応するモーフィング機能をつけてほしいです。草の揺れとか背景マップに使いたいです。
次回のアップデートに考えて頂けたらと思います。
Post Reply