ワープポイントを作ろう

オブジェクトをワープさせる
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WarpPoint : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
// (考え方)触れた瞬間にボールに新しい位置情報をセットする。
// 「0.5f」のように「小数」を使用する場合には必ず「f」を書くこと(ポイント)
// 「f」は「float(浮動小数点)」の略
other.gameObject.transform.position = new Vector3(-3, 0.5f, -3);
}
}







複数のワープポイントに対応させる
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WarpPoint : MonoBehaviour
{
// ★改良
public Vector3 pos;
private void OnTriggerEnter(Collider other)
{
// ★改良
other.gameObject.transform.position = new Vector3(pos.x, pos.y, pos.z);
}
}


【2018版】BallGame(全25回)
他のコースを見る
オブジェクトをワープさせる
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WarpPoint : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
// (考え方)触れた瞬間にボールに新しい位置情報をセットする。
// 「0.5f」のように「小数」を使用する場合には必ず「f」を書くこと(ポイント)
// 「f」は「float(浮動小数点)」の略
other.gameObject.transform.position = new Vector3(-3, 0.5f, -3);
}
}







複数のワープポイントに対応させる
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WarpPoint : MonoBehaviour
{
// ★改良
public Vector3 pos;
private void OnTriggerEnter(Collider other)
{
// ★改良
other.gameObject.transform.position = new Vector3(pos.x, pos.y, pos.z);
}
}


ワープポイントを作ろう