Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(m_key))
        {
            Ms3D.GetComponent <MassSpringSystem3D>().Gravity = true;
        }

        if (Input.GetKeyUp(m_key))
        {
            Ms3D.GetComponent <MassSpringSystem3D>().Gravity = false;
        }
    }
    // Update is called once per frame
    void FixedUpdate()
    {
        if (Input.GetKeyDown(m_key))
        {
            Vector3[] jiggleForces = new Vector3[Ms3D.VertCount];
            float     xNoise       = Random.Range(-50, 20);
            float     yNoise       = Random.Range(-50, 20);
            float     zNoise       = Random.Range(-50, 50);
            foreach (var indexedPrimitive in spawner.Primitives)
            {
                int index = indexedPrimitive.Key;

                GameObject primi = indexedPrimitive.Value;

                jiggleForces[index].x = xNoise;
                jiggleForces[index].y = -zNoise;
                jiggleForces[index].z = yNoise;
            }
            Ms3D.externalForcesBuffer.SetData(jiggleForces);
            if (Input.GetKeyUp(m_key))
            {
                Ms3D.GetComponent <MassSpringSystem3D>().Gravity = false;
            }
        }
    }