Skip to content

Instantly share code, notes, and snippets.

@nabesi777
Created October 16, 2018 23:35
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/e2f2bcf2a126bfe92b739d3ea7b35d1c to your computer and use it in GitHub Desktop.
Save nabesi777/e2f2bcf2a126bfe92b739d3ea7b35d1c to your computer and use it in GitHub Desktop.
一定時間以上当たり判定があると回転するオブジェクト
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateFloor : MonoBehaviour
{
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter(Collider collider)
{//Playerの当たり判定があった時に”Rotate”呼び出し
if (collider.gameObject.CompareTag("Player"))
{
StartCoroutine("Rotate");
}
}
void OnTriggerExit(Collider collider)
{//Playerの当たり判定が離れた時に”Rotate”をストップ
if (collider.gameObject.CompareTag("Player"))
{
StopCoroutine("Rotate");
}
}
IEnumerator Rotate()
{//3秒経過後に回転する
yield return new WaitForSeconds(3);
transform.rotation = Quaternion.Euler(new Vector3(20f, 0, 0));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment