Created
October 16, 2018 23:35
-
-
Save nabesi777/e2f2bcf2a126bfe92b739d3ea7b35d1c to your computer and use it in GitHub Desktop.
一定時間以上当たり判定があると回転するオブジェクト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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