(スクリプト)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WarpMove2 : MonoBehaviour
{
void Start()
{
StartCoroutine(Warp());
}
private IEnumerator Warp()
{
while(true)
{
yield return new WaitForSeconds(3f);
var pos = Random.Range(-10, 10);
var pos2 = Random.Range(-10, 10);
transform.position = new Vector3(pos, 0.01f, pos2);
}
}
}
(実行・確認)
- スクリプトを追加したオブジェクトが3秒ごとに、ランダムに位置を変えれば成功です。


