コード例 #1
0
ファイル: boatPhysics1.cs プロジェクト: robindegroot/BoatGame
    void AddUnderWaterForces()
    {
        float Cf = BoatPhysicsMath.ResistanceCoefficient(
            water,
            boat.velocity.magnitude,
            modifyBoatMesh.CalculateUnderWaterLength());
        List <SlammingForceData> slammingForceData = modifyBoatMesh.slammingForceData;

        CalculateSlammingVelocities(slammingForceData);

        float      boatArea = modifyBoatMesh.boatArea;
        float      boatMass = VisbyData.mass;
        List <int> indexOfOriginalTriangle = modifyBoatMesh.indexOfOriginalTriangle;

        for (int i = 0; i < underWaterTriangleData.Count; i++)
        {
            TriangleData triangleData = underWaterTriangleData[i];

            vector3 forceToAdd = Vector3.zero;
            forceToAdd += BoatPhysicsMath.BuoyancyForce(water, triangleData);
            forceToAdd += BoatPhysicsMath.ViscousWaterResistanceForce(water, triangleData, Cf);
            forceToAdd += BoatPhysicsMath.PressureDragForce(triangleData);
            int originalTriangleIndex = indexOfOriginalTriangle[i];

            slammingForceData slammingData = slammingForceData[originalTriangleIndex];

            forceToAdd += boatPhysicsMath.SlammingForce(slammingData, triangleData, boatArea, boatMass);

            boatRB.addForceAtPosition(forceToAdd, triangleData.center);
        }
    }
コード例 #2
0
ファイル: Point.cs プロジェクト: 2000prcs/match3-unity
 public static Point fromVector(vector3 v)
 {
     return(new Point((int)v.x, (int)v.y));
 }
コード例 #3
0
 void Start()
 {
     startingPoint = transform.position;
 }