ワープポイントを作ろう

ワープポイント
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 = pos;
}
}


【2022版】BallGame(全27回)
他のコースを見る
ワープポイント
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 = pos;
}
}


ワープポイントを作ろう