Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active October 24, 2016 02:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/ef1733693aca182add718da17328460b to your computer and use it in GitHub Desktop.
Save tsubaki/ef1733693aca182add718da17328460b to your computer and use it in GitHub Desktop.
タップした位置にパーティクルエフェクトを追加する
using UnityEngine;
public class TapEffect : MonoBehaviour
{
[SerializeField] ParticleSystem tapEffect; // タップエフェクト
[SerializeField] Camera _camera; // カメラの座標
void Update()
{
if(Input.GetMouseButtonDown(0))
{
// マウスのワールド座標までパーティクルを移動し、パーティクルエフェクトを1つ生成する
var pos = _camera.ScreenToWorldPoint(Input.mousePosition + _camera.transform.forward * 10);
tapEffect.transform.position = pos;
tapEffect.Emit(1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment