Ejemplo n.º 1
0
        void FixedUpdate()
        {
            if (body == null)
            {
                body = gameObject.AddComponent <Rigidbody>();
            }

            Vector3 force  = Vector3.zero;
            Vector3 torque = Vector3.zero;

            int count = m_buoyancy.Length;

            if (count == 0)
            {
                body.Sleep();
                return;
            }

            for (int i = 0; i < count; i++)
            {
                FBuoyancyPart buoyancy = m_buoyancy[i];
                if (buoyancy == null)
                {
                    continue;
                }
                if (!buoyancy.enabled)
                {
                    continue;
                }

                buoyancy.usingGravity = body.useGravity;
                buoyancy.UpdateForces(heights[i] + new float3(samplePoints[i].x, NeoOcean.oceanheight, samplePoints[i].z), normals[i], body);

                force  += buoyancy.force;
                torque += buoyancy.torque;
            }

            body.maxAngularVelocity = maxAngularVelocity;
            body.AddForce(force);
            body.AddTorque(torque);
        }
Ejemplo n.º 2
0
        void Update()
        {
            int count = m_buoyancy.Length;

            for (int i = 0; i < count; i++)
            {
                FBuoyancyPart buoyancy = m_buoyancy[i];
                if (buoyancy == null)
                {
                    continue;
                }
                if (!buoyancy.enabled)
                {
                    continue;
                }

                samplePoints[i] = buoyancy.transform.position;
            }

            GerstnerWavesJobs.UpdateSamplePoints(samplePoints, _guid);
            GerstnerWavesJobs.GetData(_guid, ref heights, ref normals);
        }