ワープポイントの作成


ワープポイント
using UnityEngine;
public class WarpPoint : MonoBehaviour
{
public Vector3 pos;
public AudioClip sound;
private CharacterController controller;
void OnTriggerEnter(Collider other)
{
if (other.gameObject.name == "Player")
{
controller = other.GetComponent<CharacterController>();
controller.enabled = false;
AudioSource.PlayClipAtPoint(sound, Camera.main.transform.position);
other.transform.position = pos;
Invoke("Reset", 0.01f);
}
}
void Reset()
{
controller.enabled = true;
}
}

【Unity6版】VR_Dungeon(全18回)
他のコースを見る

ワープポイント
using UnityEngine;
public class WarpPoint : MonoBehaviour
{
public Vector3 pos;
public AudioClip sound;
private CharacterController controller;
void OnTriggerEnter(Collider other)
{
if (other.gameObject.name == "Player")
{
controller = other.GetComponent<CharacterController>();
controller.enabled = false;
AudioSource.PlayClipAtPoint(sound, Camera.main.transform.position);
other.transform.position = pos;
Invoke("Reset", 0.01f);
}
}
void Reset()
{
controller.enabled = true;
}
}

ワープポイントの作成