Skip to content

Instantly share code, notes, and snippets.

@nabesi777
Created October 10, 2018 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nabesi777/7d3ce6c85640fcf0adaec07462472be4 to your computer and use it in GitHub Desktop.
Save nabesi777/7d3ce6c85640fcf0adaec07462472be4 to your computer and use it in GitHub Desktop.
キャラクターの動きを一時的に止める
using System.Collections.Generic;
using UnityEngine;
using System;
class Trapcol : MonoBehaviour
{
public ChaCon2 CC; //”ChaCon2”スクリプトがアタッチされたPlayerをインスペクター上で格納
OnTriggerEnter(Collider collider)
{//トラップタグをもつオブジェクトへ当たった時
if (collider.gameObject.CompareTag("Trap"))
{//指定したスクリプトを無効化
CC = CC.GetComponent<ChaCon2>();
CC.enabled = false;
    //3秒後に無効にしたスクリプトを有効化
Invoke("Restart", 3.0f);
}
}
void Restart()
{
CC.enabled = true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment