動く床の作り方


自動的に動く床
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveFloor : MonoBehaviour
{
private Vector3 pos;
void Start()
{
// MoveFloorオブジェクトの位置情報をposの中に代入する。
pos = transform.position;
}
void Update()
{
// (試してみしょう!)
// 「Time.time * 10」にするとどんな変化があるか確かめてみよう。
// 「Time.time, 30」にするとどんな変化があるか確かめてみよう。
transform.position = new Vector3(pos.x, pos.y + Mathf.PingPong(Time.time, 5), pos.z);
}
}


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

自動的に動く床
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveFloor : MonoBehaviour
{
private Vector3 pos;
void Start()
{
// MoveFloorオブジェクトの位置情報をposの中に代入する。
pos = transform.position;
}
void Update()
{
// (試してみしょう!)
// 「Time.time * 10」にするとどんな変化があるか確かめてみよう。
// 「Time.time, 30」にするとどんな変化があるか確かめてみよう。
transform.position = new Vector3(pos.x, pos.y + Mathf.PingPong(Time.time, 5), pos.z);
}
}


動く床の作り方