MoveFloorX.cs
using UnityEngine; public class MoveFloorX : MonoBehaviour { private Vector3 initialPosition; void Start() { initialPosition = transform.position; } void Update() { transform.position = new Vector3(Mathf.Sin(Time.time) * 20.0f + initialPosition.x, initialPosition.y, initialPosition.z); } }
MoveFloorY.cs
using UnityEngine; public class MoveFloorY : MonoBehaviour { private Vector3 initialPosition; void Start() { initialPosition = transform.position; } void Update() { transform.position = new Vector3(initialPosition.x, Mathf.Sin(Time.time) * 20.0f + initialPosition.y, initialPosition.z); } }
MoveFloorZ.cs
using UnityEngine; public class MoveFloorZ : MonoBehaviour { private Vector3 initialPosition; void Start() { initialPosition = transform.position; } void Update() { transform.position = new Vector3(initialPosition.x, initialPosition.y, Mathf.Sin(Time.time) * 20.0f + initialPosition.z); } }
補足
MoveFloorX.csはX軸方向の動き。
MoveFloorY.csはY軸方向の動き。
MoveFloorZ.csはZ軸方向の動き。