Unity 音乐可视化(音乐频谱控制物体的运动)

来源:互联网 发布:加拿大游戏公司 知乎 编辑:程序博客网 时间:2024/05/12 06:24

1.实现思想:通过改变物体的坐标值在update函数中实时更新物体的位置。

using UnityEngine;using System.Collections;public class NewBehaviourScript : MonoBehaviour {    private GameObject gamObj;// Use this for initializationvoid Start () {        gamObj = GameObject.Find("CubeTest");}// Update is called once per framevoid Update () {        float val = Random.RandomRange(-1.0f,1.0f);        gamObj.transform.position = new Vector3(0, 0, 0);        gamObj.transform.position = gamObj.transform.position + new Vector3(val,0,0);}}

效果如下:


0 0