Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Making a sail boat sail.

Discussion in 'Scripting' started by Deleted User, Jul 14, 2023.

  1. Deleted User

    Deleted User

    Guest

    So i want to make a sail boat actully sail! My plan is to make the wind a gameobject and then raycast towards the sail of the sail boat and give the player the ability to rotate the sails.

    But what i am wondering is if there are a better way to do this or if you have another and more effektiv way.
     
  2. zulo3d

    zulo3d

    Joined:
    Feb 18, 2023
    Posts:
    510
    You could take the dot products of the wind, sail and boat direction to create a force vector and apply it to the boat's rigidbody using AddForce().

    Raycasts would only be necessary if you was creating a boat simulator where the user could create/model their own boat and then test to see how it performed.
     
    KillDashNine likes this.
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    I found and used (for my Pilot Kurt game) a really cool airplane physics package designed to make real airplane flight in Unity. You simply define wing airfoils: wings, stabilizer, tail, fuselage, sail, whatever.

    A sailboat sail is just a vertical airfoil after all.

    You would need to model the dynamic keel force, which is the opposite force that keeps a sailboat actually tracking forward rather than just blowing sideways with the wind.

    And you'd need the uprighting force of the keel ballast playing against the buoyancy of the hull... honestly it sounds like what you're attempting is totally within reach with these parts. I'd be curious to see how you get along with it!!

    https://github.com/kurtdekker/Aircraft-Physics

    Discussion video:

     
    CodeRonnie and All_American like this.
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    I decided to try my hand at making a sailboat.



    For now I'm gonna hang onto the day job.
     
  5. zulo3d

    zulo3d

    Joined:
    Feb 18, 2023
    Posts:
    510
    shhh. just pretend it's a submarine.
     
    Kurt-Dekker likes this.
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    Too soon? :)
     
  7. All_American

    All_American

    Joined:
    Oct 14, 2011
    Posts:
    1,528
    LOLOLOLOLOLOLOLOLOLOL

    I don't buy it @Kurt-Dekker ....
     
  8. Deleted User

    Deleted User

    Guest

    @Kurt-Dekker, Since this was just for fun i played around with the package you recomended and found that it worked quite well out of the box!

    At first my boat also hade some shinking thoughts but if you change some of the values and play around with sizes it worked fine. Thanks for the tip!
     
    Kurt-Dekker likes this.
  9. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    You beat me to it! Awesome... I only made that boat video above then set it aside. I will go back and see how that sailboat thing works. Did you just make a single vertical airfoil? Tell us all about it!!!
     
  10. Deleted User

    Deleted User

    Guest

    @Kurt-Dekker

    So i did try 2 sails/foils but i found out that i becomes quit wierd at that part my boat started bugging out a'lot specially when you hit something. Sometimes it just flew away from no where, i recomend only going with one else it becomes hard to make it work. I never tried to space them out which i should probely try when i get to it.

    I also tried to make a speed boat that uses the foils as hydro foils, it did not work at all my guess is that the water you use needs to help the boat generate lift. The hard point is to truly simulat wind you actully need to take in to account alot more then a normal person thinks.

    Okay as you can see in the image these are the simple and basics sailing types and how you should position the sail. To give more insight sailing is all about chatching wind but what many people get wrong is that when you sail you only rotate your sails and thats wrong. Sail boats have the ability to tighten the sails which we want to do when sailing in option 3 and 2 you can see the numbers in the picture. But when sail in option one we wont to losen up the sails to catch more wind, and this is where the hard point of making sailing come to life with programing.
     

    Attached Files:

  11. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    You could make a big 3D sail billowed left and right with a Blendshape.

    With another blendshape you could go from the middle to a rippling luffing effect.

    Then when the sail builds angle relative to inbound wind it fills up, when you let out the sheet it just luffs and wiggles in the wind, mostly flat looking...