LoginSignup
18
19

More than 5 years have passed since last update.

Unityでスマホのタッチエフェクト実装

Last updated at Posted at 2014-07-30

概要

スマホゲームでよくあるタッチした部分に波紋のような
エフェクトを実装する方法

スクリプト

Test.cs

// 再生したいEffectのプレハブを指定する
public GameObject Effect01 = null;

// タッチエフェクトを仮実装
if(Input.GetMouseButtonDown(0))
{
    // タッチした画面座標からワールド座標へ変換
    Vector3 pos = Camera.main.ScreenToWorldPoint (new Vector3 (Input.mousePosition.x, Input.mousePosition.y, 5.0f));
    // 指定したエフェクトを作成
    GameObject go = (GameObject)Instantiate (Effect01, pos, Quaternion.identity);

    // エフェクトを消す
    Destroy(go, 0.4f);
}

雑感

GetMouseButtonDown()じゃないほうが綺麗な気もしますが
とりあえずということで。

18
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
19