分からないものは仕方がないので、別の方法を見つけるしかない!
と考え直して、次の一手です。
しかし・・・
案が出てこない・・・
処理が0.3秒なのでピースを押した時に処理を0.3秒遅延させるのはどうだろうか?
とう言う事で
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class GameManager : MonoBehaviour {
public GameObject[] PieceBt; //ピースの取得
new Transform transform; //トランスフォーム取得用変数
private int PieceID; //ピースNo代入用変数
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update()
{
}
public void PushPiece(int a)
{
PieceID = a;
Invoke("PieceMove", 0.3f); //移動処理を0.3秒後に呼び出す
}
void PieceMove()
{
transform = PieceBt[PieceID].GetComponent(); //ピースa番目のTransform情報を取得
float z = transform.localEulerAngles.z; //Transformからローカル角度を取得
transform.DORotate(new Vector3(0f, 0f, z + 90), 0.3f); //ピースを90°0.3秒かけて回転させる
}
}
ピースを押してからInvokeで0.3秒後に移動処理を入れてみました。
しかし回転自体0.3秒遅れるので意味が無いことに気が付きました。(;^_^A
結果は当然✖です。
それなら回転処理後に0.3秒のウエイトをかけてみるのは
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class GameManager : MonoBehaviour {
public GameObject[] PieceBt; //ピースの取得
new Transform transform; //トランスフォーム取得用変数
private int PieceID; //ピースNo代入用変数
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update()
{
}
public void PushPiece(int a)
{
transform = PieceBt[PieceID].GetComponent(); //ピースa番目のTransform情報を取得
float z = transform.localEulerAngles.z; //Transformからローカル角度を取得
transform.DORotate(new Vector3(0f, 0f, z + 90), 0.3f); //ピースを90°0.3秒かけて回転させる
Invoke("PieceMove", 0.3f); //ピースの回転後0.3秒の遅延を発生させる
}
void PieceMove()
{
return;
}
}
この記事へのコメント