using System.Collections; using System.Collections.Generic; using UnityEngine; public class Wave : MonoBehaviour { private float y; // 縦に動かす量 // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { y += 0.1f * Time.deltaTime; // 縦に動かす量を0.1ずつ帰る if(y >= 0.1f) // もし、yが0.1以上になったら、 { y *= -1f; // yに-1かける } transform.position += transform.TransformDirection(Vector3.forward * Time.deltaTime) + new Vector3(0,y,0); // 前方に進みながら縦にyの分だけ動かす } }
オブジェクトを波状に動かす
2020年6月27日

コメント