Home Game Development unity – Compute thrust utilized to ship’s sails relying on sailSize, sailState and relative angle of wind

unity – Compute thrust utilized to ship’s sails relying on sailSize, sailState and relative angle of wind

0
unity – Compute thrust utilized to ship’s sails relying on sailSize, sailState and relative angle of wind

[ad_1]

I’m making an attempt to calculate the pace of a ship, relying on many elements.

  • the pace of the wind
  • the relative angle between the sails ahead and the wind ahead. remodeled into angleSpeed
  • the ‘dimension of the sail relative to whole dimension of all sails of that mast’
  • the sail’s ‘state’

Simple system for the sail’s ‘state’:

  • 0 – sail is furled (packed) – not in use
  • 1 – sail is unfurled and raised – not in use however nonetheless catching wind as its unpacked
  • 2 – sail is unfurled and set – in use and catching full wind.

Then the calculation of pace needs to be divided by every sail, and in reality every sail calculates its personal dimension and its sizePercetage out of all sailSizesTotal.

So mainly I’m making an attempt to.

  1. test the relative angle of mast/wind
  2. test state of sail underneath that mast
  3. calculate pace of that sail based mostly on the sail’s sizePercentage, the relativeAngle and the sail’s state
  4. all these values are between 0.000f and 1.000f
  5. calculate mast pace (all sails underneath that mast)
  6. calculate ship pace (all masts)

The best approach to present what I’m making an attempt to attain is by trying on the code beneath I feel:

    float mizzenMastAngle = mizzenMast.localEulerAngles.y;

    float relMizzenToWindAngle = GetRelativeAngle(mizzenMastAngle, windAngle);

    float mizzenMastAngleSpeed = WindManager.occasion.GetSpeedFromWindAngle(relMizzenToWindAngle);

    float mizzenMastSpeed = 0f;
    foreach (SailControl sailControl in mizzenMastSails)
    {
        float sailSizePercentage = sailControl.GetSail().sizePercentage;

        float sailStateMultiplier = 0.1f;
        change (sailControl.GetSail().state)
        {
            case 0:
                sailStateMultiplier = 0.1f;
                break;
            case 1:
                sailStateMultiplier = 0.25f;    //Debug values, change later to smaller
                break;
            case 2:
                sailStateMultiplier = 1f;
                break;
        }
        float thisSailSpeed = sailSizePercentage * sailStateMultiplier * mizzenMastAngleSpeed; // Range: 0.0f - 1.0f for these variables.
        mizzenMastSpeed += thisSailSpeed;

    }
    float mainMastAngle = mainMast.localEulerAngles.y;
    float foreMastAngle = foreMast.localEulerAngles.y;

...
ship.pace = mizzenMastSpeed + mainMastSpeed + foreMastSpeed;

Specifically this line is what I need assistance with because it does not work as meant:

float thisSailSpeed = sailSizePercentage * sailStateMultiplier * mizzenMastAngleSpeed; // Range: 0.0f - 1.0f for these variables.

I feel right here mizzenMastSpeed ought to have a max of 1?

Basically if all mizzen sails are getting used it needs to be maxspeed for mizzenmastSpeed.

If solely half the sails are getting used, however some are furled and a few are set, all these calculations ought to return the proper pace for that mast, then for the opposite masts, based mostly on what states, angle and proportion of whole is getting used.

Then I wish to apply all these speeds collectively to the ship in an accurate means.

So if I take down a single sail on 1 mast it ought to lower the general pace of the ship in keeping with the scale of that sail, the angle of the wind it was catching and its state.

I hope somebody may help me with this.

Code for getting whole dimension and particular person dimension of sails:

    int totalsize = 0;
    foreach (SailControl sailC in mizzenMastSails)
    {
        int dimension = sailC.GetSail().dimension;
        totalsize += dimension;
    }

    float sizePercentage = 0;
    float totalPercentage = 0;
    foreach (SailControl sailC in mizzenMastSails)
    {
        int dimension = sailC.GetSail().dimension;
        sizePercentage = (((float)dimension) / totalsize); // Range 0f - 1f
        sailC.SetSizePercentage(sizePercentage);
        totalPercentage += sizePercentage;
    }

EDIT:

My progress to this point:

    float thisSailSpeed = sailSize * sailStateMultiplier;
    mizzenMastSpeed += thisSailSpeed;
    }
    // Multiply by worth based mostly on relative wind angle between mast and wind.
    mizzenMastSpeed *= mizzenMastAngleSpeed;

    totalSpeed = mizzenMastSpeed + mainMastSpeed + foreMastSpeed + staysSpeed;
    totalSpeed *= windSpeed;
    totalSpeed *= speedMax;

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here