Mercurial > hg > Members > kazuma > JungleforUnity
view Assets/Application/Scripts/DeathZone.cs @ 13:e297afe0889d default tip
Add Prefab.
author | Kazuma Takeda |
---|---|
date | Tue, 07 Feb 2017 20:49:26 +0900 |
parents | b55d586dd4eb |
children |
line wrap: on
line source
using System.Collections; using System.Collections.Generic; using UnityEngine; public class DeathZone : MonoBehaviour { private GameObject target; private Vector3 firstPoint; public delegate void HitCallback (int n); public HitCallback hitcallback; public void SetHitCallback (HitCallback hc) { this.hitcallback = hc; } private void Start () { target = GameObject.FindGameObjectWithTag ("Player"); firstPoint = target.transform.position; } private void Update () { Vector3 pos = target.transform.position; this.transform.position = new Vector3 (pos.x, this.transform.position.y, pos.z); } private void OnTriggerEnter (Collider col) { if (col.tag == "Player") { target.transform.position = firstPoint; if (hitcallback != null) hitcallback (1); } } }