的当て3Dアプリを作成しました。
2Dから3Dにすることでアプリの書き出し時間が長くなったり、macbookの処理スピードも少し落ち、画面に時々ノイズが入るようになりました。
iphoneXでテスト運用してみるときちんと動くようですが、開発途中の処理落ちには十分注意した方が良さそうです。
Unityに組み込まれているテライン操作や物体のエフェクトなど便利なツールもあるのでうまく使いこなせるとビジュアル的によくなりそうです。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class IgaguriController : MonoBehaviour
{
public void Shoot(Vector3 dir)
{
GetComponent<Rigidbody>().AddForce(dir);
}
public void OnCollisionEnter(Collision collision)
{
GetComponent<Rigidbody>().isKinematic = true;
GetComponent<ParticleSystem>().Play();
}
void Start()
{
//Shoot(new Vector3(0, 200, 2000));
}
void Update()
{
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class IgaguriGenerator : MonoBehaviour
{
public GameObject igaguriPrefab;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
{
GameObject igaguri = Instantiate(igaguriPrefab) as GameObject;
igaguri.GetComponent<IgaguriController>().Shoot(new Vector3(0, 200, 2000));
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Vector3 worldDir = ray.direction;
igaguri.GetComponent<IgaguriController>().Shoot(worldDir.normalized * 2000);
}
}
}