Blenderで作成したオブジェクトをUnityで正常に再生する方法

Blenderでアニメーション付きのオブジェクトを作成しました。

そのオブジェクトをDuplicateで複数作成させた後に、Unityの実行ボタンを押すと正常に全てのオブジェクトのアニメーションが再生されます。
[97773-スクリーンショット-2017-07-15-141406.png|97773]
しかし、アニメーションの再生のタイミングを制御するために、Animatorで一度Emptyを通してboolで条件定義をさせると、一つのオブジェクトのアニメーションしか再生されません。
[97774-スクリーンショット-2017-07-15-141452.png|97774]

<コード内容>

using System;
using System.Collections.Generic;

namespace UnityEngine.XR.iOS
{
public class UnityARHitTestExample : MonoBehaviour

{
		public Transform m_HitTransform;
	    public float life_time = 3f;
	    float time = 0f;

	//animation
	public Animator anim;

	void start () {
		time = 0;
		anim = GetComponent<Animator> ();

	}

    bool HitTestWithResultType (ARPoint point, ARHitTestResultType resultTypes)
    {
        List<ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface ().HitTest (point, resultTypes);
        if (hitResults.Count > 0) {
            foreach (var hitResult in hitResults) {
                Debug.Log ("Got hit!");
                m_HitTransform.position = UnityARMatrixOps.GetPosition (hitResult.worldTransform);
                m_HitTransform.rotation = UnityARMatrixOps.GetRotation (hitResult.worldTransform);
                Debug.Log (string.Format ("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z));
                return true;
            }
        }
        return false;
    }
	
	// Update is called once per frame
	void Update () {
		if (Input.touchCount ==3 && m_HitTransform != null)
		{
			var touch = Input.GetTouch(0);

			if (touch.phase == TouchPhase.Began)
			{
				var screenPosition = Camera.main.ScreenToViewportPoint(touch.position);
				time += Time.deltaTime;

				ARPoint point = new ARPoint {
					x = screenPosition.x,
					y = screenPosition.y
				};

				//Animation start
				anim.SetBool ("IsCube,true");

				if (time > life_time) {
					gameObject.SetActive (true);
				}
						
                // prioritize reults types
                ARHitTestResultType[] resultTypes = {
                    ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent, 
                    // if you want to use infinite planes use this:
                    //ARHitTestResultType.ARHitTestResultTypeExistingPlane,
                    ARHitTestResultType.ARHitTestResultTypeHorizontalPlane, 
                    ARHitTestResultType.ARHitTestResultTypeFeaturePoint
                }; 
				
                foreach (ARHitTestResultType resultType in resultTypes)
                {
                    if (HitTestWithResultType (point, resultType))
                    {
						return;
                    }
                }
			}
		}
	}


}

}

原因をご教示ください。

Good thing you fixed the images, I think I understand your problem now. The animation overwrites the rotation you have set for each of the objects individually, so all your objects are in the same place. A solution to this would be to give each object a parent GameObject:

  1. Create a new empty GameObject
  2. Drag and drop the model onto that GO to make it its child
  3. Copy the parent GameObject and rotate that instead of the actual model

The animation will then rotate relatively to the rotated parent.

Another thing that caught my eye is these lines:

if (Input.touchCount ==3 && m_HitTransform != null)
{
  var touch = Input.GetTouch(0);
  if (touch.phase == TouchPhase.Began)

This cannot work properly.
You basically expect the user to create three touches in the exact same frame. The touch with index 0 is the first touch, and it needs to be fresh (TouchPhase.Began) while the other two needed touches are already existing. Users will have a very low chance of actually triggering this.

== Original answer before added code and images ==

I cannot tell you where the problem is without seeing any code, but I guess it’s one of these:

  • You’re using the static keyword somewhere in your script without knowing what it does
  • You put the script controlling the parameter on one object only

If you post some code, I could probably edit this answer to something more precise.