動く床の作り方


自動的に動く床
using UnityEngine;
using System.Collections;
public class MoveFloor : MonoBehaviour {
private Vector3 pos;
void Start () {
// MoveFloorオブジェクトの位置情報をposの中に代入する。
pos = transform.position;
}
void Update () {
// (ポイント)
// Mathf.PingPong(float t, float length);
// tの値を0からlengthの範囲内で行ったりきたりさせる。
this.gameObject.transform.position = new Vector3(pos.x, pos.y + Mathf.PingPong(Time.time, 5), pos.z);
}
}


【旧版】BallGame(全25回)
他のコースを見る

自動的に動く床
using UnityEngine;
using System.Collections;
public class MoveFloor : MonoBehaviour {
private Vector3 pos;
void Start () {
// MoveFloorオブジェクトの位置情報をposの中に代入する。
pos = transform.position;
}
void Update () {
// (ポイント)
// Mathf.PingPong(float t, float length);
// tの値を0からlengthの範囲内で行ったりきたりさせる。
this.gameObject.transform.position = new Vector3(pos.x, pos.y + Mathf.PingPong(Time.time, 5), pos.z);
}
}


動く床の作り方